aspose file tools*
The moose likes Servlets and the fly likes Servlet Access from URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Access from URL" Watch "Servlet Access from URL" New topic
Author

Servlet Access from URL

Vins Ver
Greenhorn

Joined: Oct 14, 2009
Posts: 11
Hi All...

i have come across a problem and inspite of going through a large amount of oracle documentation, am unable to come to a solution.

We have an 2 servlets in our application which is being accessed by external application via a URL. This access URLs cannot be changed in the external applications.

We are using Oracle 10g application server.

for eg.:
URL 1. http://<serverName>:<port>/servlets/HelloJava
URL 2. http://<serverName>:<port>/servlet/HelloWorld

Please note that one URL has context name as 'servlets' and other has it as 'servlet'.

Now when we deploy an application in Oracle 10g, it asks fr URL mapping. I provided this URL mapping as 'servlets' (i couldnt figure out any other way to avoid changing the URL being accessed.).

Thus now URL 1 is working fine, but URL 2 gives a 404(file not found) error, which is obvious as there is no application context as servlet. I can access HelloWorld Servlet using the URL http://<serverName>:<port>/servlets/HelloWorld , i.e. using 'servlets' and not 'servlet'.

Is there any way win which i can access HelloWorld by the URL 2.

Cheers..
Vins

Mohammed Yousuff
Ranch Hand

Joined: Oct 17, 2007
Posts: 198
Vins it will be better if you update the url mapping properties from web.xml file... I believe that you first application was hit for that both URL. as you don't have HelloWorld in you first application it throws 404...

So check you Web.xml and let us know ...


My Thoughts : http://passion4java.blogspot.com
Try not to become a man of success but rather to become a man of value.
Vins Ver
Greenhorn

Joined: Oct 14, 2009
Posts: 11
Hi Yousuff,

web.xml URL-mapping would only be relevant after the web-context(URL mapping of the application and not the servlet). The web-context in this case is 'servlets'. The SERVLET URL mapping is done in web.xml thus i can access it with URL http://<serverName>:<port>/servlets/HelloWorld and not with URL http://<serverName>:<port>/servlet/HelloWorld .

Thus whatever servlet URL mapping i give in the web.xml it would come only after http://<serverName>:<port>/servlets/
e.g.: if i give servlet URL mapping as myFolder/HelloWorld then i can access HelloWorld by http://<serverName>:<port>/servlets/myFolder/HelloWorld

Regards,
Vins
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

If you cannot change the context of your web applications, you could stick a proxy in front of your servlet container(s) that redirects accordingly.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Vins Ver
Greenhorn

Joined: Oct 14, 2009
Posts: 11
Hi Paul,

Any pointers on how to achieve that?

Thanks.
Vins
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You could do it with something like IIS or Apache Http server and mod_proxy.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Access from URL
 
Similar Threads
Change in servlet-class & servlet-name in web.xml not reflected? Why?
Running Servlets, have a question
problem while giving a url pattern in filter mapping
Problem redirecting to HTTPS from jsp Links
Problem redirecting to HTTPS from jsp Links