----------------------------------------------------------------
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!!!
----------------------------------------------------------------
I have a servlet which sets/gets session ok when called as
a servlet.
I would like to use this servlet from JSSI but the session
does not get initiated.
If I initate a session by calling the servlet directly,
then call the servlet through a jhtml, the jhtml call
picks up the session, ok.
Servlet source is attached.
Any help appreciated.
Andy
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SeasonDates extends HttpServlet
{
/**
* Handle the GET and HEAD methods by building a simple web page.
* HEAD is just like GET, except that the server returns only the
* headers (including content length) not the body we write.
*/
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out;
// set content type and other response header fields first
response.setContentType("text/html");
// then write the data of the response
out = response.getWriter();
boolean flag = false;
String user = null;
HttpSession session = request.getSession(false);
if (session != null) {
out.println("We already have a session<br />");
user = (String) session.getValue("user");
out.println("user: "+user+"<br />");
} else {
// first time we are called for this user
flag = true;
out.println("First time session<br />");
session = request.getSession(true);
user = request.getRemoteUser();
if (user != null) {
session.putValue("user",user);
} else {
session.putValue("user","Unknown");
}
}
}
}
--
Andy Brady Email : [EMAIL PROTECTED]
Web Services Group Tel : +44(0)118 9499252
E.C.M.W.F. Fax : +44(0)118 9869450
Shinfield Park, Reading, RG2 9AX Web : http://www.ecmwf.int
--
--------------------------------------------------------------
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]