Servlets Section Index | Page 2
How can we find out the number of ServletContext currently active in a servlet container?
Hi,
No, there are no references in the specifications for that.
As far as I know there is nothing available for that, especially if you need something that is portable or not server specific.
If y...more
How do you create a browser cookie that persists to a different domain?
I have server1 and server2(12.23.34.45).
Note: I have no control over server2 and it's a cgi server.
Server1 creates a request to server2. In response, server2 feeds back an html page with the h...more
From a servlet, how do I access files and directories on the client's file system?
You cannot access the client's directory structure using a web application (jsp, servlet, javascript, html) because of security issues. You may need to look into an applet or other client based a...more
How can I read parameters from a multipart/form-data upload form?
[That is, given the form:
<FORM ACTION="/servlet/FooServlet"
ENCTYPE="multipart/form-data"
METHOD=POST>
What is your name? <INPUT TYPE=TEXT NAME='submitter'><br>
...more
How should I configure JBuilder7 to work on servlets?
JBuilder doesn't really need of any additional setup for working with Servlets. Just create a new Project and creare a new Web Application. Then when you want to create a new file, just select "s...more
How could I use NTLM Authentication to authenticate via Windows NT Authentication for a servlet based intranet-application ?
[There was a great discussion of this at http://www.jguru.com/faq/viewquestion.jsp?EID=393110 The code below seems to be the final solution, but I recommend reading the thread to mak...more
How do I use HttpServletRequest.getHeaderNames() to get the names of the headers of the HTTP request?
Well, it is that simple, this is java basics, and is based on the simple exanple that is provided in the Java API Documentation, for java.util.Enumeration. I strongly suggestion to read it when y...more
What is the role of the controller in MVC architecture?
The role of controller is to dictate what to do behind the scenes and what to display in the view next.
1. Controller receives a request
2. Controller decides the requested activities based on re...more
How can I set parameters in a JSP, something equivalent to setAttribute on a request object? That is, I need to do setParameter in order to read it as getParameter in the servlet.
[One solution is: I am assuming you're referring to "intercepting" a request, then checking/modifying the values. If so, have a look at one of the newer features of the Servlet API, Filters.
]
...more
How to deploy and run a simple servlet on websphere?
If you are new to websphere, it seems to be strange at least initially,to deploy the simple servlet. One way you can do is you need to generate a war file. For this you can use Application Assembl...more
How to do a simple session timeout?
In WEB-INF/web.xml, use the following incantation:
<webapp>
.
.
<session-config>
<session-timeout>30</session-timeout> ...more
How can I access a configuration and/or log.properties file (stored under WEB-INF) in a web application?
I place the log.properties and the appconfig.xml file in the WEB-INF/classes directory. (appconfig.xml is the other configuration file I spoke of.)
I get the locations as a URL object using the ...more
When using a dispatcher and calling .forward(), will doGet() or doPost() be called in the target servlet?
The RequestDispatcher will call the servlet's service method. If your servlet extends javax.servlet.http.HttpServlet the same 'do' method will be called automatically by the service method, depend...more
How do I keep Tomcat 4.1.x from persisting Session Objects?
[Full question: I have an application that I am migrating to a clustered environment with multiple Tomcat 4.1.x servers. I am in the process of changing the persistent session data to another for...more
There is an HttpSessionBindingListener for changes to the session. Is there anything similar for changes of ServletContext?
There is an HttpSessionBindingListener for changes to the session. Is there anything similar for changes of
ServletContext?