I have the follow problem.
I put a string in servlet session and then I try to read the value from a jsp page.
When I get the object session within jsp page I obtain a null value. here is the 
servlet and jsp source code.


// -*- mode: java -*-
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public final class insIntoSession extends HttpServlet implements CostantiServlet
{
    private    HttpSession session = null;
    public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
    {
        String saluti = new String("Ciao Salvatore");
        session = req.getSession(false);
        try
        {

            if (session == null)
                log("Non sono riuscito a creare la sessione ");
            else
                log("Inserisco nella sessione il valore "+saluti);

            session.putValue("insIntoSession.saluti",saluti);
            res.sendRedirect("/sgti/jsp/vediSessione.jsp");
        }
        catch(Exception e)
        {
            throw new UnavailableException(this,DB_ERROR_CONNECTION);
        }
    }

    /**
    * Before dying out...
    */
    public void destroy() {
        log("Servlet insIntoSession distrutta.");
    }

}



<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page session="false" %>

<HTML>
<HEAD>
<TITLE>Vedi Sessione JSP</TITLE>
</HEAD>
<BODY bgcolor=#FFFFFF>
<%

   HttpSession session = request.getSession(false);
   String saluti = null;

   if (session == null)
%>
      Non era presente nessuna sessione<BR>
<%
   else
   {
      saluti = (String)session.getValue("insIntoSession.saluti");
      if (saluti == null)
%>
         Non ci sono saluti per te<BR>
<%
      else
      {
%>
         Ecco i tuoi saluti <%= saluti %>
<%
      }
   }
%>
</BODY>
</HTML>






Tanks in advance salvatore

--------------------------------------
Name: Salvatore Soldatini
E-mail: [EMAIL PROTECTED]
Tel.: (06)71036892
Date: 08/08/00
Time: 14:23:20
--------------------------------------



---------------End of Original Message-----------------

--------------------------------------
Name: Salvatore Soldatini
E-mail: [EMAIL PROTECTED]
Tel.: (06)71036892
Date: 08/09/00
Time: 10:57:35
--------------------------------------

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to