• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get ther servlet name from the Httprequest / servletContext

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

Arthik
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic