Hi,
My problem with jsp-servlet-jsp is still there(titled 'Sessions').  I have
hosted it on a server which uses JSERV.

The following is the exact code of 3 programs.  Please check it and let me
know what is going wrong.

call.jsp: http://www.winaquiz.com/jsp/call.jsp
It puts 2 values 'name1' and 'name2' in a session and calls VServlet.
(scroll down for exact script)

VServlet.class:  Adds one more element 'name3' into the session and calls
second.jsp (scroll down for exact script)

second.jsp: Lists all the elements in the session and total no. of elements.
(scroll down for exact script)

Very straight-forward and simple program.  You can run it using the link
above.

What is happening?
It sets name1 and name2 into session and calls the Servlet.  The name3 in
servlet is ignored.  The servlet calls second.jsp.  This program lists name1
and name2 and the number of element is shown as 2.  *name3 is missing in
action* at the servlet side.  The exact code follows.  This time there is no
TomCat involved.  Only JServ. (jsdk2.0).

I will be too happy if somebody can help me.  I am stuck with it for the
last 2 days.  It is a very basic problem.

call.jsp:
--------
<%@ page language = "java" %>
<html>
<%
 session.putValue("name1","dantus1");
 session.putValue("name2","dantus2");

response.sendRedirect(response.encodeRedirectUrl("http://www.winaquiz.com/se
rvlet/VServlet"));
%>
</html>

VServlet.java:
--------------
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class VServlet extends HttpServlet
{
 public void init(ServletConfig config)throws ServletException
 {
  super.init(config);
 }
 public void service(HttpServletRequest request,HttpServletResponse
response)throws IOException,ServletException
 {
  HttpSession session = request.getSession(true);
  session.putValue("name3","from session");
 //  System.out.println("In servlet"+session.getValue("name3"));

response.sendRedirect(response.encodeRedirectUrl("http://www.winaquiz.com/js
p/second.jsp"));
  return;
 }
}

second.jsp
----------
<%@ page language = "java" %>
<html>
<body>
<%

out.println("Second Page<br>");
String[] sessionNames = session.getValueNames();
String name;
int i=0;
out.println("Length : "+sessionNames.length+"<br>");
while (i < sessionNames.length)
{
 name = sessionNames[i++];
 out.println(name+":");
 out.println(session.getValue(name)+"<br>");
} // end of while loop for session names


%>
</body>
</html>


Thanks in advance.

Regards,

Dantus

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to