Rupesh Choubey wrote:

> [snip]
> ok, for all the JSP guru's......could anyone HELP with documentation /
> examples for URLEncoding and sesssion management strategies with JSP. we
> need to try and make the concepts work and some examples would be really
> really helpful....thanks for all your help.....
>

For background information on session management concepts, and the two techniques
used to maintain sessions (cookies and URL rewriting), I would start with the
servlet trail in the Java Language Tutorial
(http://java.sun.com/docs/books/tutorial) and study the session-related stuff in
one of the popular servlet-related books.  Session management concepts are
identical for servlets and JSP pages.

As for what you actually have to do in your JSP pages, that's actually pretty
simple.  If your clients are guaranteed to have cookies enabled, the only thing
you need to do is have "session='true'" in your <%@ page %> directive, and the JSP
compiler will generate code to make sure your page participates in a session
appropriately.

On the other hand, if you need to do sessions with clients that do not necessarily
have cookies enabled, you also need to do the URL encoding around *every*
hyperlink in your pages that refers back to this page (or servlet), or another
page (or servlet) in your application.  A simple example -- let's assume you have
a link that returns the user to the main menu, like this:

    Go to the <a href="menu.jsp">Main Menu</a>.

To have it encoded when necessary, just do this:

    Go to the <a href="<%= response.encodeURL("menu.jsp") %>">Main Menu</a>.

and your URL will be encoded if necessary (i.e. cookies not in use).  If cookies
are being used, the encodeURL() method will return the hyperlink unmodified.
That's pretty much all there is to the mechanics.

>
> Rupesh.
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to