Servlets Section Index | Page 41
What work is happening towards creating Servlet API v2.3?
No. It provides a fair bit of housekeeping that you'd just have to do yourself. If you need to do something regardless of whether the request is e.g., a POST or a GET, create a helper method and...more
In the Servlets 2.1 spec, you can set a Servlet Context Attribute. For example, getServletContext().setAttribute("counter", new foo.Counter()); . You can also access (or initialize) thes...more
The servers involved in handling and processing a user's request break down into a few basic types, each of which may have one or more tasks it solves. This flexibility gives developers a great d...more
Since there's no telling which directory the servlet engine was launched from, you should always use absolute pathnames from inside a servlet. Usually I pass in the root directory in an InitPar...more
[ Short answer: there are several ways to do this, including use a RequestDispatcher use a URLConnection or HTTPClient send a redirect call getServletContext().getServlet(name) (deprecated, does...more
Can a servlet add request parameters into a request object before passing on the request to another servlet or jsp?
I am currently doing this - passing a request object to a jsp. However, you need JRun to do so. JRun has some packages included which define classes called JRunServletRequest and JRunServletResp...more
I need to communicate from my servlet to another independent process. Can I use the RequestDispatcher instead of opening a socket connection?
No. The RequestDispatcher can only send a message to a servlet or JSP running inside the same servlet engine. You either have to open a socket, use native code, or use Runtime.exec() to spawn a ...more
I've installed the JSWDK and it says I've run out of environment space when I try to start the server. How do I increase the amount of environment space under Windows?
The end of your CONFIG.SYS file should include a line like the following: SHELL=C:COMMAND.COM C: /E:4096 /P This assumes your COMMAND.COM file is in your root level C: directory and you wish yo...more
How can I download a file (for instance, a Microsoft Word document) from a server using a servlet and an applet?
Try telling the applet to call getAppletContext().showDocument("http://foo.com/whatever/blah.doc"). That makes the browser responsible for fetching and saving the document (including pu...more
How does the performance of JSP pages compare with that of servlets? How does it compare with Perl scripts?
The performance of JSP pages is very close to that of servlets. However, users may experience a perceptible delay when a JSP page is accessed for the very first time. This is because the JSP page ...more
The kit for developing servlets, containing the Servlet API classes and tools, used to be called the Java Servlet Development Kit (JSDK). Then Sun renamed the Java Development Kit (JDK) to the Ja...more
No. A JTA transaction must start and finish within a single invocation (of the service() method). Note that this question does not address servlets that maintain and manipulate JDBC connections,...more
Yes, you can invoke the JSP error page and pass the exception object to it from within a servlet. The trick is to create a request dispatcher for the JSP error page, and pass the exception obje...more