I could only find examples with Tomcat for servlet sessions. The
JSP->Servlet->JSP demo does not use sessions.

Here are sample code snippets as requested -->

-----------------------------------
Here is the Servlet code that I am using:

          HttpSession session = request.getSession(false);
        if(session == null) {
            System.err.println("Session is null redirecting back to the
registration jsp");
            response.sendRedirect(Links.REGISTER_JSP);
        }
-----------------------------------
Here is the JSP code:

<%@ page import="com.evolution.examples.RegistrationFormConstants,
                 com.evolution.examples.RegistrationFormBean,
                 com.evolution.examples.Links" %>
<%@ page errorPage="../error/error.html" %>
<%--
 * Basic registration example. Is used for entry of a name and email
address.
--%>
<jsp:useBean id="registrationFormBean" scope="session"
class="com.evolution.examples.RegistrationFormBean" />
<jsp:setProperty name="registrationFormBean" property="*" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
        <TITLE>Web Applications - Login</TITLE>
        <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
        <META HTTP-EQUIV="Cache-Control" CONTENT="no-store">
            <LINK REL="STYLESHEET" HREF="<%= Links.STYLE_SHEET %>"
TYPE="text/css"></LINK>
    </HEAD>
    <BODY>
        <H2>Web Applications Standards Template - Example</H2>
        <FORM ACTION="<%= Links.REGISTER_SERVLET %>" METHOD="POST">

            <TABLE>
                <TR>
                    <TD ALIGN="RIGHT">* First Name</TD>
                    <TD><INPUT TYPE="text" SIZE="20" NAME="<%=
RegistrationFormConstants.FIRST_NAME %>" VALUE="<jsp:getProperty
name="registrationFormBean" property="firstName" />"></TD>
                    <TD CLASS="error"><%=
registrationFormBean.getErrorMsg(RegistrationFormConstants.FIRST_NAME)
%></TD>
                </TR>
                etc.... etc.... etc....
            </TABLE>
            <P>
                <INPUT TYPE="SUBMIT"></INPUT>
            </P>
        </FORM>
    </BODY>
<HTML>
-----------------------------------

Any help would be appreciated.

Many Thanks... Raj.

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: 10 April 2000 17:17
To: Rajesh Shah
Cc: [EMAIL PROTECTED]
Subject: Re: Session using Tomcat


Rajesh Shah wrote:

> This is a fundamental problem escpecially if you are using the Model 2
> architecture and the servlet is being used as the controller. Has anyone
got
> any workarounds?

Tomcat does support sessions being shared across servlets and JSP pages in
the same
web application.  Do the session examples that come with Tomcat work
correctly for
you?  If not, you don't have it installed correctly.  If they do, there is
some
other logic issue in your pages/servlets that will require code snippets to
debug.

Note that URL rewriting support was not present in Tomcat 3.0 -- you had to
use
cookies.  It is present in the most recent releases of 3.1 beta, and will be
in the
3.1 final release, so that it works fine either with or without cookies.

Craig McClanahan


>
> -----Original Message-----
> From: Javier Borrajo [mailto:[EMAIL PROTECTED]]
> Sent: 10 April 2000 16:05
> To: Rajesh Shah
> Cc: [EMAIL PROTECTED]
> Subject: Re: Session using Tomcat
>
> Hi, some people in my company evaluated TomCat and had
> this problem, so they recommend Resin now.
> See www.caucho.com
>
> Regards
>
>     Javier Borrajo
>     www.tid.es
>
> Rajesh Shah wrote:
>
> > I ahve been using ServletExec for the last three months and have not
> > encountered any problems. I am currently researching Tomcat and having
> > difficulties with sessions.
> >
> > I have a JSP which is a simple registration page. The form element in
the
> > JSP submits to a Servlet which is turn gets the session object from the
> > request and retreives a bean from the session. Even thought I set the
> scope
> > of the bean to the session, I cannot retrieve the current session. When
I
> do
> > request.getSession(false) I get a null object, and if I say
> > getSession(true), then I get a new session.
> >
> > has nybody else had problems with this? I am using WinNT, Tomcat 3.1
> >
> > Raj.
> >
> > PS. By browser is set to accept cookies!
> >
> >
>
===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> > 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".
> 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".
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