• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get ther servlet name from the Httprequest / servletContext

 
arthik babu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
How can I get the servlet name from the Http Request / Servlet conext?

Arthik
 
Vijitha Kumara
Bartender
Posts: 3952
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get the servlet name from the Http Request / Servlet conext?


Servlet name is defined in web.xml. What are you looking for? You access a servlet using a particular URL-pattern mapped to a servlet name in the web.xml.
 
mukesh chandan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arthik babu wrote:
Hi,
How can I get the servlet name from the Http Request / Servlet conext?

Arthik


hi arthik...
hope you know about DD(deployment descriptor)..
here a servlet class is mapped to the url pattern through a servlet name...
and i think there is no method in HttpRequest interface that will give you servlet name...
you also better check this
http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html";
and if you check ServletContext interface you will find

java.util.Enumeration getServletNames()
Deprecated. As of Java Servlet API 2.1, with no replacement.
This method was originally defined to return an Enumeration of all the servlet names known to this context. In this version, this method always returns an empty Enumeration and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API.

java.util.Enumeration getServlets()
Deprecated. As of Java Servlet API 2.0, with no replacement.
This method was originally defined to return an Enumeration of all the servlets known to this servlet context. In this version, this method always returns an empty enumeration and remains only to preserve binary compatibility. This method will be permanently removed in a future version of the Java Servlet API.

or you find out
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html




 
arthik babu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I have a requirement , to create a new request in the server side , based on the original request. So before making a URL connection. I need to check if the server name and port is same as the original request then I need to check the if the servlet name is available in the local server. If these conditions are not satisfied then only I need to create a HTTP request.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!