I found a bug a while back in the encodeURL() method in Tomcat 3.1.  I 
was using the struts link tag to generate all my links so that struts 
would append the session id to the urls.  Struts uses Tomcat's 
encodeUrl() method, which only adds the session id if the link is within 
your own app, e.g. it won't add a session id if you try to link to yahoo 
(unless you're developing a web page for yahoo!).

Anyway, if you run Tomcat 3.1 on port 80, its encodeUrl() method 
incorrectly thinks the url is outside of your app and does not append the 
session id.  When my app tried to go to a page that required a login, it 
kept redirecting back to the login page because the session id was 
missing.  I couldn't get off the login page!

This is fixed in Tomcat 3.2.  Alternatively, run Tomcat 3.1 on anything 
but port 80 (not usually practical).

Hope this helps.  It sounds similar to your problem.

Chris Smith


>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 1/29/01, 3:58:13 PM, "Michael Mok" <[EMAIL PROTECTED]> wrote regarding 
Server Port Problem HELP:


> Hi

> Sorry to post such a long email. I am absolutely stump with a session
> problem that have been bugging my STRUTS based application.

> I have encountered some session persistence problem with my application
> trying to track if the user has logged on. I am not sure if it is due to 
the
> fact that the website uses Tomcat 3.1 or STRUTS.

> My application presents a logon page which when the user logons on
> successfully, a session is created and a "user" object stored in the 
session

> eg LogonAction.class
>     HttpSession session = request.getSession();
>     session.setAttribute(Constants.USER_KEY, user);

> Next the application will forward the user to the main page. User can 
then
> click on an action such "view data from a table" which will forward to an
> action class to display the rows.


> All my action class check if  the "user" object exists within the session
> otherwise they will be directed to the logon page.

> eg ShowColumnAction.class

>  org.teatimej.initialise.User user = (org.teatimej.initialise.User)
> session.getAttribute(Constants.USER_KEY);
>  if (user == null) {
>   if (servlet.getDebug() >= 1)
>       servlet.log(" User is not logged on in session "
>                       + session.getId());
>   return (servlet.findForward("logon"));
>  }

> The odd thing here is that user will always be directed back to the logon
> page upon clicking on the first action URL on the main page. However 
after
> they logon the second time, all action URL works fine.

> The website support personnel said that it could be due to the fact that 
my
> URL have a server port attached even though the server port is port 80.

> I noticed that my logon form does not have a base html tag (if that may 
be
> the problem) and the form URL (does not contain port 80) is

> http://www.webappcabaret.com/teatimej/logon_wac.jsp

> The form action (after logon_wac.jsp is displayed on the browser) is

> <form name="logonForm" method="POST" action="logonwac.do">

> The URL found on the main page have the following URL

> <a href="http://webappcabaret.com:80/teatimej/edittable.do?action=new">

> The subsequent logon form action (logon_wac.jsp) is

> <form name="logonForm" method="POST"
> action="logonwac.do;jsessionid=To1015mC34669985688752114At">

> What have I done to STRUTS such that the logon page above includes a
> jsessionid as compared to the first logon exact form (but with no
> jsessionid) ?

> I have been advised by the website support personnel to remove the port
> number from the URL.

> I check the STRUTS link tag and found that the server port is always 
append
> to the server name. Here is the code where STRUTS builds up the URL..

> RequestUtils.class

>     public static String absoluteURL(HttpServletRequest request, String
> path) {

>         try {
>             URL url = new URL(request.getScheme(),
>                               request.getServerName(),
>                               request.getServerPort(),
>                               request.getContextPath() + path);
>             return (url.toString());
>         } catch (MalformedURLException e) {
>             return (null);
>         }

>     }

> I cannot see any option to instruct STRUTS not to include the serverport
> when building the URL. However the server port may be a red herring.

> Have I got off the rails?

> TIA

> Michael Mok
> www.webappcabaret.com/teatimej

Reply via email to