Elena Palanca wrote:

> Thanks for the answer, till here everything is OK.
> What happen after this?
> For example, if I send the encoded URL in a JSP where the user have to fill
> some forms and then submit a button and send all data to a servlet.
> The servlet will find in his request the sessionID or I have to pass it
> again using encode URL?
> Thanks
> Elena
>

I am assuming that you have the destination of your form being a servlet.

Yes, the servlet will receive a session ID with it.  This needs to be true on
*every* request that comes in, so that the server knows this request is part
of the same session.  What happens next depends on how you are going to
generate the next reply to the user.  Two general approaches are common in a
JSP world:

(1) Servlet Forwards Beans To Another JSP Page

In this scenario, the servlet accepts the parameters entered on the form, and
does whatever processing your application requires.  Then, it stores any
information that will be needed to produce the next HTML page that the user
sees in beans (typically putting them in the user's session), and forwards
control to the next JSP page like this:

    RequestDispatcher rd =
        getServletContext().getRequestDispatcher("/next_jsp_page.jsp");
    rd.forward(request, response);

In the "/next_jsp_page.jsp" page, you actually produce the results response
for the user, again encoding URLs whenever you create them.

(2) Servlet Generates Its Own HTML

In this case, the servlet itself creates the HTML response after processing
the input parameters.  Again, anytime you create a hyperlink back in to this
application, you must call encodeURL() to ensure that session continuity is
maintained, even if cookies are turned off.

The Servlet Trail in the Java Language Tutorial
(<http://java.sun.com/docs/books/tutorial>) has a nice explanation of how
these session concepts work.  The examples don't include JSP pages, but the
concepts are all the same -- after all, the JSP page is just compiled into a
servlet that uses the same servlet API your own servlets do, so it follows the
same rules.

Craig

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to