this is weird...all files look fine...

Try priting session values before putting and getting it...

One more thing you can do...
Instead of using response.sendRedirect, use <jsp:forward>
The diff between two is:
When you say response.sendRedirect, this is technically a new request to web
server(request goes out of app-server), so this might be causing some
session problem...But when you <jsp:forward>, reqeust remains within
app-server so its a same request to web server so you might get expected
results...Try doing this...(not sure it will work but trial and error..)

Just have a stupid question(not related with session but just curious..)You
are not using servlet
chaining feature...right??
Because i read somewhere that servlet chaining is not allowed in tomcat or
jserv(not sure)...
but u can read docs online...

Nishit
-----Original Message-----
From: iZone Infotech [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 23, 2001 3:22 AM
To: [EMAIL PROTECTED]
Subject: Session


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

===========================================================================
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