• 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

Hiding a servlet from the world

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks,
We have an application whose Main servlet is configured in web.xml as main (com.bla.bla.MainServlet). So, it can be accessed: http://<server> ort/webappName/main
I have wrote another servlet myServlet (com.bla.bla.MyServlet) such that it gets the main request; does some processing and hands it over to MainServlet. It does all this by modifying web.xml and request dispatcher (main points to MyServlet and appMain points to MainServlet; MyServlet performs a request dispatch to appMain).
I want to know if it is possible to hide MainServlet from the world (clients could access MainServlet as: http://<server> ort/webappName/appMain). Basically I want to force all requests to go through MyServlet.
Thanks in advance,
Musafir
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe your first servlet could stick some sort of marker object in the request attributes. Check for in in the other one. If it's not there, you know they didn't go thru the right path - you could forward them there or serve back a "don't do that" page.
[ October 28, 2002: Message edited by: Dave Landers ]
 
Sharad Agarwal
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dave - Thanks for the response. That is exactly what I have done for now. I have a flag attribute which I set in MyServlet and I check for it in MainServlet. But to accomplish this I had to decompile, modify and recompile the application code (MainServlet).
I was wondering if there is some way to accomplish this in Weblogic. To have a servlet meant for internal purposes only; to be called exclusively by application entities.
Thanks in advance,
Musafir

Originally posted by Dave Landers:
Maybe your first servlet could stick some sort of marker object in the request attributes. Check for in in the other one. If it's not there, you know they didn't go thru the right path - you could forward them there or serve back a "don't do that" page.
[ October 28, 2002: Message edited by: Dave Landers ]

 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then maybe what you really want is a filter.
http://edocs.bea.com/wls/docs70/webapp/filters.html
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use servlet mapping in web.xml like this:
<web-app>
<servlet>
<servlet-name>MainServlet</servlet-name>
<servlet-class>com.bla.bla.MainServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.bla.bla.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
 
It's just a flesh wound! Or a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic