We help IT Professionals succeed at work.

How to redirect a request to different servlets by identifying URL patterns in JBoss

Hi,

I am working on writing a Servlet that will route requests to appropriate servers received from differnt clients based on URLs received in request. Target deployment environment is JBoss for Servlet. Client can be a WebService response (XML Text). Any one can provide a sample code or base code for reference.
Comment
Watch Question

Author

Commented:
Just spelling mistake in earlier question..:)
Commented:
I'm not familiar with JBOSS, but I presume it uses web.xml like any other J2EE server. If so, you can use servlet mappings, such as below. This example sends any URL of the form http://www.foo.com/umesh/whatever/foo.jsp to the servlet class specified by the name "My Silly Little Servlet".
	<servlet id="myservlet123">
		<servlet-name>My Silly Little Servlet</servlet-name>
		<servlet-class>com.mlps.umesh.MyServletClass</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>My Silly Little Servlet</servlet-name>
		<url-pattern>/umesh/*</url-pattern>
	</servlet-mapping>

Open in new window

Author

Commented:
Thanks bpmurray for reply. As you pointed out, JBOSS web.xml is confirmed to J2EE standards for Web Deployment and change in web.xml will resolve routing issue. My problems was bit different. In real word, I am getting a response from WebService as XML. XML will contain different URLs that, I need to redirect. My approach for this problem is to write a servlet that will actually do pattern matching to take out URL's in response and route them to differnt servers. Instead of doing any parsing and redirection manually (thr' servlet code), can any one provide better approach which will give a portable solution like  use of JBOSS feature like RewriteValve or similar.

May be, I was not very clear with question.
Commented:
Ahh - now I see. Have you considered using redirect or forward? There's a nice technote on this here: http://java.sun.com/developer/EJTechTips/2003/tt0513.html#2

Author

Commented:
Yah...Solution I got was not exactly I was looking for. But definately pointing me to right direction.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.