Servlets Section Index | Page 3
Why shouldn't we make the service() method synchronized?
[Full question:
When we implement singlethreadmodel it means that only one
thread can access the service method at a time.now my question is ,why can't we achieve the same thing my making the se...more
What is the maximum length of the data we can send through the get() method?
It is dependent upon the browser and server, however in
RFC 2068 it states
Servers should be cautious about depending on URI lengths
above 255 bytes, because some older client or proxy
implemen...more
When a first request is made to a servlets the init() method is called for the first time and after that the threads will serve the subsequent requests. What will happen when 2 requests are made to a servlet at the same time immediately after the server has restarted?
The App server will queue up the requests. Then, they will be processed with the first one (the App server decides) calling the init method and the second waiting until it's finished to throw the...more
Why do I get the error: SAX parser fatal error: External entity not found: "http://java.sun.com/dtd/web-app_2_3.dtd"?
[This happens because Sun's Web site is down, so the servlet engine can't find the remote copy of the web.xml DTD at that URL.]
Well, you can download the dtd and point the document reference ins...more
How to notify the user to save data before the session expires? Then if the user does not respond, then save the data.
If you are going to save the data even if the user does not repond, then why not save it right at the beginning anyway?
Cheers
-raj
[See also
the original forum thread
Is there a way to dete...more
How to suppress the URL shown in the address bar?
How to suppress the URL shown in the address bar?
No matter what page the customer is on, I want to just show http://sitename.com and no JSP page name.
I'd like to dynamically generate a PHP file from a servlet, then have Apache execute it. Is this possible? Setting the Content-type does not seem to help.
[I am working with Apache 2 with Tomcat 4.1.
I am integrating some system that was built with servlets, with some PHP project. What I need to do is generate PHP files from servlets.
Problem is tha...more
How can I access an NNTP newsgroup using JSP or Servlets?
Your servlet must know how to speak NNTP, or call a library that does.
There are NNTP implementation in the following packages:
JavaMail: See the JavaMail:NNTP FAQ subtopic.
Jakarta Commons...more
How can I keep track of how may times my servlet is called?
See How do I implement a hit counter in Servlets or JSP? for a definitive answer.
Why does cookie.getMaxAge() always return -1 (regardless of real expiry)?
By default, the maxAge is set to a negative number.
You should set the maximum age with setMaxAge(int seconds) with a positive number to set your own expiry right after creating the cookie. Use ...more
Can an Application Scope Variable be clustered?
[ For example I want to load some settings when the application starts and i keep that object in the application scope so that any part of the application can use that information. Now if the envi...more
How to find the parent directory of a servlet?
try this..
to get the URL
java.net.URL url;
try {
url = new java.net.URL(new java.net.URL(req.getRequestURL
().toString()),"../");
} catch (java.net.MalformedURLException e) {
&nbs...more
How can I call the get method of a servlet automatically, when a *different* HTML page is loaded?
[I thought of using a image on the html page and sending the request to the servlet for the image.]
The image will work if the user enables images in his/her browser. Other solutions (JavaScript...more
How to get international unicode characters from a a form input field/servlet parameter into a string?
[
I have a servlet based app that generates and processes HTML forms. I would like to support mutiple languages/character sets that will be stored in unicode UTF-8 in the database. I am setting th...more
What is the best way to generate a universally unique object ID? Do I need to use an external resource like a file or database, or can I do it all in memory?
[I need to generate unique id's that will be used for node 'ID' attribute values within XML documents. This id must be unique system-wide. The generator must be available to a number of servlets t...more