hi....
thanks for your help fernando...
i test your code, and it work....
But i make some changes and then i have the same problems...
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
{
HttpSession session = req.getSession( true );
java.util.Date crDate;
* probe lv_probe=null;
resp.setContentType( "text/html" );
PrintWriter pw = resp.getWriter();
pw.println( "<html><head></head><body>" );
pw.println( "<h2>BasicServlet</h2><br>" );
if ( session.isNew() )
{
crDate = new java.util.Date();
* lv_probe = new probe("user");
pw.println( "New session<br>" );
session.putValue( "thedate", crDate );
* session.putValue("object",lv_probe);
pw.println(
"Cr time (msecs): " + crDate.getTime() + " " +
lv_probe.getNombre() +
"<br>" );
}
else
{
pw.println( "OLD session<br>" );
crDate = (java.util.Date)session.getValue( "thedate" );
* lv_probe = (probe)session.getValue("object");
if ( crDate == null )
{
pw.println( "WOW!! Lost session object<br>" );
crDate = new java.util.Date();
session.putValue( "thedate", crDate );
}
else
pw.println(
"Cr time (msecs): " + crDate.getTime() + " " +
lv_probe.getNombre() +
"<br>" );
}
pw.println( "</body></html>" );
}
}
class probe
{
private String nombre;
public probe(String nombre)
{
setNombre(nombre);
}
public void setNombre(String newNombre)
{
nombre = newNombre;
}
public String getNombre()
{
return nombre;
}
}
Now i store an instance of a class of my creation...
I get an error code 500 from the web server...
If anybody probe this code...have the same problem
with this changes ????
what i am doing wrong ????
thanks for your help!!!!!!!
--- Fernando Salazar <[EMAIL PROTECTED]> escribi�:
At 02:31 PM 5/8/00 -0500, you wrote:
>
>>I'am not talking about classes that i lost when i
>>reload my servlets...
>>
>>I lost objects that i store in memory, that manage
>>the state of users between requests...
>>i just found a document in
>>
>>http://www.magiccookie.com/computers/apache-jserv/#Class Path and Class
>>Reloading
>>
>>that talk about this situation...they suggest that i save
>>my objects in a permanent store before the reload of the
>>servlets, how i save objects in a permanent store ???
>>
>>have somebody another solution ???
>>
>>thanks for any help....
>
>Possibly I'm confused about your question. I made a test servlet that
>writes init/destroy messages to the log,
>and with the following doGet() method:
>
> protected void doGet( javax.servlet.http.HttpServletRequest req,
> javax.servlet.http.HttpServletResponse resp )
> throws javax.servlet.ServletException,
>java.io.IOException
> {
>
> HttpSession session = req.getSession( true );
> java.util.Date crDate;
>
>
> resp.setContentType( "text/html" );
> PrintWriter pw = resp.getWriter();
>
> pw.println( "<html><head></head><body>" );
>
> pw.println( "<h2>BasicServlet</h2><br>" );
>
> if ( session.isNew() )
> {
> crDate = new java.util.Date();
> pw.println( "New session<br>" );
> session.putValue( "thedate", crDate );
> pw.println( "Cr time (msecs): " + crDate.getTime()
>+ "<br>" );
> }
> else
> {
> pw.println( "OLD session<br>" );
> crDate = (java.util.Date)session.getValue(
>"thedate" );
> if ( crDate == null )
> {
> pw.println( "WOW!! Lost session object<br>" );
> crDate = new java.util.Date();
> session.putValue( "thedate", crDate );
> }
> else
> pw.println( "Cr time (msecs): " +
>crDate.getTime() + "<br>" );
> }
> pw.println( "</body></html>" );
> }
>
>As you can see, it stores an object in a browser session. The first time
>you access this servlet from a browser, you will see something
>like:
>
> BasicServlet
>
> New session
> Cr time (msecs): 957829663227
>
>then, when you hit refresh, you'll see:
>
> BasicServlet
>
> OLD session
> Cr time (msecs): 957829663227
>
>Next, if you recompile the class and copy the new version to the repository
>directory, and then refresh your browser once again, you will see the OLD
>session message and the original time, *even though* you can see in the log
>that the servlet instance has been destroyed and re-loaded.
>
>So, like I said, I don't see the problem -- in JServ session data *clearly*
>outlives the servlet instance that created it. I believe the magic-cookie
>article is referring to state data that you store via instance variables in
>the servlet itself. Any such data would indeed be lost when the servlet is
>reloaded.
>
>Good luck.
>
------------------------------------------------------------------------------------
Obtenga su direcci�n de correo gratuita en http://serverlx.gye.ramt.com/servlets/mail
___________________________________________________________________________
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