Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Access from URL

 
Vins Ver
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
Vins Ver
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vins Ver
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Any pointers on how to achieve that?

Thanks.
Vins
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do it with something like IIS or Apache Http server and mod_proxy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic