----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
Dear all,
Sorry to reopen what seems to be a sore wound but...
I have a problem with FORM GET losing the session Id. See attatched code
below.
I could not find in February's thread on this subject any concrete answer to
whether this is a bug in Apache JServ 1.1, JSDK2.0 or whether HTML form get
just
does not work this way.
Any answers would be greatly appreciated.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Test extends HttpServlet
{
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println(session.getId() + "<br>");
// this works fine
out.print("<FORM action=\"");
out.print(response.encodeUrl("/servletsdev3/Test"));
out.println("\" method=post>");
out.println("<input type=submit value=post>");
out.println("</form>");
// this does not work - the session is lost
out.print("<FORM action=\"");
out.print(response.encodeUrl("/servletsdev3/Test"));
out.println("\" method=get ENCTYPE=\"x-www-form-coded\">");
out.println("<input type=hidden value=hello>");
out.println("<input type=submit value=get>");
out.println("</form>");
// this also works fine
out.println("<a href=\"" + response.encodeUrl("/servletsdev3/Test")
+ "\">Test</a>");
out.println("</body></html>");
}
public void doPost (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
}
}
David Bell
Senior Developer
Infocom (UK) Ltd
http://www.info-com.com
mailto:[EMAIL PROTECTED]
<Insert usual disclaimer here>
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]