| products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 

WebLogic Server Frequently Asked Questions

 Previous Next Contents View as PDF  

FAQs: Server-Side Java (Servlets)

Q. How do I call a servlet with parameters in the URL?

A. The usual format of a servlet parameter is a name=value pair that comes after a question-mark (?) at the end of the URL. To access these parameters, call the getParameter() method on the HttpServletRequest object, then write code to test the strings. For example, if your URL parameters are "func=topic," where your URL appears as:

then you could parse the parameter as follows, where "req" is the HttpServletRequest object:

  String func = req.getParameter("func");
if (func.equalsIgnoreCase("topic")) {
. . . do some work

Q. How can I run multiple instances of the same servlet class in the same WebLogic Server instance?

A. If you want to run multiple instances, your servlet will have to implement the SingleThreadModel interface. An instance of a class that implements the SingleThreadModel interface is guaranteed not to be invoked by multiple threads simultaneously. Multiple instances of a SingleThreadModel interface are used to service simultaneous requests, each running in a single thread.

When designing your servlet, consider how you use shared resources outside of the servlet class such as file and database access. Because there are multiple instances of servlets that are identical, and may use exactly the same resources, there are still synchronization and sharing issues that must be resolved, even if you do implement the SingleThreadModel interface.

Q. How do I deserialize an httpsession?

A. To deserialize an httpsession, construct a utility class that uses the current thread's contextclassloader to load the user defined objects within the application context. then add this utility class to the system CLASSPATH.


Back to Top Previous Next