Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

destroy() and killing servlet threads

 
Steve Ohi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a problem viewing changes which I am making to my servlets. I am trying to change the output of this servlet from:
This is output from SimpleServlet
to
This is output from SimpleServlet99
I tried using destroy() at the end of this code but it didn't seem to work. Anyone suggestions ?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Test2Servlet extends HttpServlet
{
public void doGet (
HttpServletRequestrequest,
HttpServletResponseresponse
) throws ServletException, IOException
{
PrintWriterout;
Stringtitle = "Simple Servlet Output";
response.setContentType("text/html");
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from SimpleServlet99.");
out.println("</BODY></HTML>");
out.close();
destroy();
}
}

[This message has been edited by Steve Ohi (edited November 06, 2000).]
 
Paul Wetzel
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont see why your code wouldn't work. Have you stopped and restarted your server. Some servers require that you stop and then restart your server to reload servlets.
hope this helps
paul
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The destroy method should never be called by your code. It is called by the servlet engine just before shutdown or removing your servlet instance for some other reason.
Whether your servlet engine will automatically notice a change and reload the servlet class depends on the particular engine. JRun does a nice job. With Tomcat 3.1 I always stop and restart just to be sure.
Bill
 
Prasad Charasala
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your code is missing
<code>
out = response.getWriter();
</code>
Probably your new code has not compiled. If it is compiled, servlet container did not loqded your new class file. Stop and then start your server.

------------------
Prasad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic