Reputation: 11791
I am interesting in how's a http request processed by web container like Jboss, supposed there are many war
in JBoss, How does Jboss know a request should pass to one of them? And I want to if i had used struts2
. How is reqeust finally passed to the Action
of struts2 ? Can anybody help me to figure it out ? thanks.
Updated
say you have a same servlet mapping both in A.War and B.War like below . But they are different implement class of HttpServlet
<servlet-mapping>
<servlet-name>DeployServlet</servlet-name>
<url-pattern>/deploy/*</url-pattern>
</servlet-mapping>
What happen to JBoss http request process order if the url is /deploy/test
?
Updated
Let's make a summany, When the web container receive the Http Request to a certain resouce(*.html *.jsp etc), web container will choose a war application to process this request base on the context xml (like server.xml
in tomcat
). then, this war application will choose a servlet which defined in the Web.xml to handle the request firstly...
well, My question:
Filter
execute Http Request earlier than Servlet
?
thanks.
Upvotes: 2
Views: 1616
Reputation: 10677
First of all http request is received by the web server. Usually Servlet containers( like tomcat) and Application Servers (like JBoss) have an inbuilt web server. So Web Server or also referred as http server gets request and decides if it can handle it.
A web server can handle static content request like html, image etc. If request is for a dynamic content then it passes the request to the Servlet container.
Servlet containers are part of Java EE servers (like Tomcat and JBoss AS). Servlet container has deployment desciptor (.xml files) through which it knows about all deployed applications. And when containers start these config files gets loaded (and gets converted into Object). So using deployment descriptor mapping it decides if the request is valid and if so then the request is send to appropriate resource (like servlet ).
For details you can read life cycle of Servlet and also how contaner works.
Upvotes: 2
Reputation: 857
The servlet-mapping will be relative to the application context. If you deploy 2 wars they will have 2 different contexts. If they don't you will get a deployment error. You can set a war as the context root, so lets say you have 2 wars warA.war and warB.war deployed to your server http://my_server.com
to access resources in either war you would use:
http://my_server.com/warA/somePage
or
http://my_server.com/warB/somePage
Using the mapping you described would look like http://my_server.com/warA/deploy/
If you set either war as the context root you could access the resource as http://my_server.com/deploy/ but the server is still translating that from /deploy to warA/deploy
So there would not be any confusion as to which servlet is retrieved.
Upvotes: 2