Ciao Salvatore,
sono Mariano Pollio tlsoft Napoli
penso che il problema stia nella attivazione errata della sessione non con false ma,
con true.
Fammi sapere altrimenti cerco nel mio repertorio. Ciao
------------------------
From: Salvatore Soldatini <[EMAIL PROTECTED]>
Subject: Fw: Session object through servlet and jsp
Date: Wed, 9 Aug 2000 10:57:35 +0100
To: [EMAIL PROTECTED]
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
---------------End of Original Message-----------------
--------------------------------------------------------
Name : Pollio
E-mail: [EMAIL PROTECTED]
Wap : http://www.geocities.com/mpollio/index.wml
Date: 08/09/2000
Time: 19:46:28
--------------------------------------------------------
e per te [EMAIL PROTECTED] ciao
___________________________________________________________________________
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