• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

access a servlet usin its name

 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a big doubt here, I have the simplest deploys file ever.


the application is in the tomcat's webapps directory like this :
tomcat
|- webapps
|- mytest
|- WEB-INF
....

and I try to access this with my browser with the URL : http://localhost:8080/mytest/MyWerver, but this fails. It seams that i can not access a servlet by using its name. The only ways to access the servlet is tu use a servlet-mapping node. So my question is :
It is possible to access a Servlet by using (only) its name ?

Thanks,
M
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is a discouraged practice and most
web containers do not allow this by default. Using a serlvet mapping is the standard.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael,

Thanks for your answer, but I still have one question how I can configurate the container to allow this ?

Regards,
M
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you said by name I thought you wanted to access the servlet by class name (which is discouraged)

You need to add a servlet maping to match your servlet name entry. I have supplied some of these pairs for you to look at. Notice each servlet tag has a corresponding servlet-mapping tag. It is the servlet-name tag that ties them together. Then you can access the servlet by using the url-mapping pattern. For example, the pattern host/web root/jstltest will match the
<url-pattern>/jstltest</url-pattern>
which is tied to <servlet-name>JSTLTagTestServlet</servlet-name>
which is tied to the actual class <servlet-class>com.sparky.servlet.JSTLTagTestServlet</servlet-class>
</servlet>

You are missing the servlet mapping..,


 
And then we all jump out and yell "surprise! we got you this tiny ad!"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic