> -----Original Message-----
> From: A mailing list about Java Server Pages specification
> and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Veronique Dupierris
>
> I am trying to encode all my links to be able to retrieve my beans
> and parameters I have saved in the session object. I tried in 3
> differents case :
>
> * for the error Page, the first problem i had, is to set a string
> variable in the page action ... <%@ page ....
> errorPage="<%newURL%>" %>
>
> *So I tried when I call other JSP files, using HREF :
> <% String newURL=response.encodeUrl("page.jsp"); %> or encodeURL()
> <A HREF="<%=newURL%>?param=value " > or directly using
> response.encodeUrl in the HREF tag.
>
> * In a form :
> <% String newURL=response.encodeUrl("page.jsp"); %>
> <FORM METHOD=POST ACTION=<%=newURL%> >
>
> In all cases,I display my session ID to verify it and each times,
> the session ID is differents !!!! I tried with both Netscape
> and IE5; I
> am using JSWDK-1.0.1.
> Could you please tell me where I did something wrong !!!!
In the examples below, each time you view one of these pages in a browser
with *cookies disabled* you should get a different session created
(pointer/reference and session id will be different) - the server cannot
know what the session ID is.
The cross links in the pages are built using encodeURL, if you click on
these links you should see the session object then remain constant across
the two pages.
I tested this using JRUN 2.3.3 and it works as I describe.
In my case the encoded url becomes something like this:
/test/session2.jsp?jrunsessionid=944650284078244912
(JSWDK-1.0.1 will be a bit different but the principle should be the same)
Note: change the '/test/' bit to the directory where you put the files.
If these example files don't work then I think you may have a bigger
problem... :-)
---------------------------
/test/session.jsp:
<HTML>
<HEAD>
<TITLE>Session Test (without Cookies)</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Session (without Cookies)</H1>
<%= session %>
<P>
<a href="<%= response.encodeUrl( "/test/session2.jsp" ) %>"><%=
response.encodeUrl( "/test/session2.jsp" ) %>"</a>
<P>
</BODY>
</HTML>
---------------------------
/test/session2.jsp:
<HTML>
<HEAD>
<TITLE>Session 2 Test (without Cookies)</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Session 2 (without Cookies)</H1>
<%= session %>
<P>
<a href="<%= response.encodeUrl( "/test/session.jsp" ) %>"><%=
response.encodeUrl( "/test/session.jsp" ) %>"</a>
<P>
</BODY>
</HTML>
> I
> also have a
> question concerning session, should I use session.getSession
> in some or
> all my JSP files ?
The default value for the session attribute in the <%@ page %> page
directive, is 'true' so a session should always be created for you, so you
shouldn't need to use request.getSession(), as the 'session' object in JSP
should already be set/created for you.
Hope that helps,
Steve
===========================================================================
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