Hi all,

I do not understand why encodeURL() is not working. Below I have the
complete code including HTML POST statement. I start by posting to
the the post_it servlet, which in turn redirects the user to the get_it
servlet. The encodeRedirectURL() in the post_it works correctly.

My problem is that the encodeURL() in the get_it servlet does NOT
append the session information to the URL.
encodeRedirectURL() DOES work in its place.

Can anyone tell me why?

I have cookies turned off. Tried both Netscape 4.61 and IE 4.72.
I am using the JWS 2.0 (preview) I received at JavaOne this year.
I am compiling against the jsdk 2.1 servlet.JAR file.
The JWS 2.0 (preview) comes preset with the session.properties file
set up with session tracking and URL rewriting turned on.
( I checked it my self )

enable.sessions=true
enable.urlrewriting=true
enable.cookies=true
enable.protocolswitchrewriting=true

session.inavalidationinterval=10000
session.swapinterval=10000
session.persistence=true
session.swapdirectory=sessionSwap
session.maxresidents=1024
session.invalidationtime=1800000
session.cookie.name=jwssessionid

Any help would be appreciated.

Thanks in advance,
Spencer Ridder
[EMAIL PROTECTED]

*********************************************************************

<HTML>
<BODY>
<FORM ACTION="http://localhost/servlet/post_it" METHOD="POST"
                        ENCTYPE="application/x-www-form-urlencoded">

<P>To test the post_it servlet click the submit button:</P>

<INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>

public class post_it extends HttpServlet{

  public void init (ServletConfig config) throws ServletException{
    super.init(config);
  }
  public void doPost(HttpServletRequest req, HttpServletResponse res)
                                  throws ServletException, IOException{

    HttpSession session = req.getSession(true);

    res.sendRedirect(
        res.encodeRedirectURL("http://localhost/servlet/get_it"));
    return;
  }
}


public class get_it extends HttpServlet{

  public void init (ServletConfig config) throws ServletException{
    super.init(config);
  }
  public void doGet(HttpServletRequest req, HttpServletResponse res)
                               throws ServletException,
IOException{
    HttpSession session= req.getSession(false);

    if(session == null){
      res.sendRedirect ("http://localhost/welcome/login.html");
      return;
    }

    PrintWriter pw = res.getWriter();
    res.setContentType("text/html");

    pw.println("<HTML>");
    pw.println("<BODY>");
    pw.print(  "<A HREF=\"");
    pw.print( res.encodeURL("http://localhost/servlet/default_page"));
    pw.println("\">Click Here</A>");
    pw.println("</BODY>");
    pw.println("</HTML>");
    pw.close();
    return;
  }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to