I am a little confused about your set-up. You say your web server is Tomcat, but you are also running Perl CGI scripts. Where are these scripts running? On a separate web server, like Apache, or on the same Tomcat server?

If your scripts are running on a separate server, there is no way to access the HttpSession objects. They live in the Tomcat server process, and would need to be exposed somehow for you to get to them. Exposing the session attributes through Cookies (as in your initial idea) is probably the easiest way, but also the most expensive. The data would be passed on each HTTP request.

Keep in mind, too, that Cookies are per-domain. If your perl script is running on a server that isn't in the same domain (or sub-domain, I think), you won't see the cookie.

When [id://Joost] talkes about a webservice type page, I believe he is suggesting having a simple JSP/Servlet running on Tomcat. Your Perl script would issue a GET request to the servlet (maybe using LWP), and the servlet would respond with the information you need, in an easily parseable format. For instance, if you had the Tomcat session id for the user, you might call GET http://your-tomcat-server/app/session_info?id=1234567, and the servlet might respond with a body of name=Joe Blow; org=IT;.

I have never heard of running Perl scripts on Tomcat, but I suppose it would be possible to create a simple wrapper Servlet that then executes the Perl script. If that is the case, and you rolled this wrapper yourself, the wrapper could provide the pertinent data from the HttpSession object as command-line arguments/environment variables.

In reply to Re: CGI for (or against) HttpSession? by crashtest
in thread CGI for (or against) HttpSession? by graff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.