on 03-22-2005 11:46 AM
Hello everybody,
I am running WAS 6.40 Snake Preview on MAX DB. Im trying to use the SAP J2EE engine as a servlet engine.
Everything works fine until I try to implement a servlet which distinguish between servlet __name__ and servlet ___alias___.
Here is a piece of my servlet code:
public class Counter extends HttpServlet{
static int classCount = 0;
int count = 0;
static Hashtable instances = new Hashtable();
public void doGet( ){
out.println(count++);
out.println(classCount++);
out.println(instances.size());
}
}
In the web.xml of my Web Module Project in the Mappings tab Ive entered following:
Servlet Name:Counter URL Pattern: Counter1
Servlet Name:Counter URL Pattern: Counter2.
And calling following URL-s:
URL1: host_name:50000/EAR_project/Counter1
URL2: host_name:50000/EAR_project/Counter2
results in:
URL1
out.println(count++) -> 1
out.println(classCount++) -> 1
out.println(instances.size()) -> 1
URL2
out.println(count++) -> 2
out.println(classCount++) -> 2
out.println(instances.size()) -> 1.
Now my question:
according to the tutorial Im reading, the instance.size in URL2 should be ____2____. And the count value should be _____1_____.
As I assume, it is not the case, because creating two URL Patterns, didnt result in creating aliases. So there is only one instance of Counter servlet on the j2ee server.
Whats wrong with my servlet?
Where should I enter those aliases in order to create two instances of my servlet?
Any help appreciated.
Regards
Pawel
Hi,
You have to create two servlet declarations in web.xml, which will point to one and the same servlet class.
<servlet>
...
-
<servlet-name>servlet1</servlet-name>
-
<servlet-class><b>class</b></servlet-class>
...
</servlet>
<servlet>
...
-
<servlet-name>servlet2</servlet-name>
-
<servlet-class><b>class</b></servlet-class>
...
</servlet>
<servlet-mapping>
-
<servlet-name>servlet1</servlet-name>
-
<url-pattern>Counter1</url-pattern>
</servlet-mapping>
<servlet-mapping>
-
<servlet-name>servlet2</servlet-name>
-
<url-pattern>Counter2</url-pattern>
</servlet-mapping>
Hope this helps
Best Regards,
Violeta Georgieva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.