Server-Side Development Section Index | Page 184
What's different in Enterprise JavaBeans 1.1?
The most significant changes are listed below:
Entity bean support, both container- and bean-managed
persistence, is required.
Java RMI-IIOP argument and reference types must be...more
How can I debug my servlet?
Hoo boy, that's a tough one.
First off, you should always do your own exception handling. An
uncaught exception can silently kill your servlet, and if you don't
know where to look in the log f...more
How can I detect whether the user accepted my cookie?
Here's a clever trick: use a redirect. Drop a cookie on the
HttpServletResponse object, then call response.sendRedirect()
to a "phase two" servlet. The "phase two" servlet the...more
How do I ensure that my servlet is thread-safe?
[See also What is the meaning of calling a method or object "thread-safe?" ]
This is actually a very complex issue. A few guidelines:
The init() method is guaranteed to be called on...more
How do I fully shut down the server?
For JWS, under Windows, pressing control-C doesn't fully shut down the
server. You should use the Admin Tool and click "Shut Down".
(Or you can hit ctl-alt-del, find "JREW" in...more
How do I get the name of the currently executing script?
Use req.getRequestURI() or
req.getServletPath(). The former returns the path to the
script including any extra path information following the name of the
servlet; the latter strips the extra path...more
How do I integrate HTML design into my Servlet?
The question can be rephrased, "How can I design a work
flow that incorporates HTML designers and programmers to build a
dynamically generated web site that will keep expanding and
growing ov...more
How do I mix JSP and SSI #include?
If you're just including raw HTML, use the #include directive
as usual inside your .jsp file.
<!--#include file="data.inc"-->
But it's a little trickier if you want the server...more
How do I send email from a servlet?
From:
James Cooper (pixel@bitmechanic.com)
GSP and GnuJSP both come with SMTP classes that make sending email very
simple. if you are writing your own servlet you could grab one of the
many SM...more
How do I support both GET and POST protocol from the same Servlet?
The easy way is, just support POST, then have your doGet method
call your doPost method:
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{...more
How do I use Session Tracking? That is, how can I maintain "session scope data" between servlets in the same application?
Session Tracking is one of the most powerful features of Servlets and JSP. Basically, the servlet engine takes care of using Cookies in the right way to preserve state across successive requests ...more
Is it the "servlets" directory or the "servlet" directory?
For Java Web Server:
on the file system, it's "servlets"
c:JavaWebServer1.1servletsDateServlet.class
in a URL path, it's "servlet"
http://www.stinky.com/servlet/DateServlet
...more
My browser says "the server returned an invalid or unrecognized response" -- what gives?
This is probably due to a NullPointerException being thrown. There's
a bug in JWS 1.1 whereby it doesn't correctly log these exceptions.
The solution is to put your doPost() method inside a tr...more
What is the HelloWorld Servlet?
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloHttpServlet extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res...more
Why doesn't my servlet work inside a tag?
If you use your servlet inside an SSI, you must use
res.getOutputStream() and not
res.getWriter(). Check the server error logs for more
details.
more