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




--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search Archives: 
<http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to