File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Problem Invoking Servlet thru Proxy Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem Invoking Servlet thru Proxy Server" Watch "Problem Invoking Servlet thru Proxy Server" New topic
Author

Problem Invoking Servlet thru Proxy Server

Kelly Dolan
Ranch Hand

Joined: Jan 08, 2002
Posts: 109
Hi! I have a problem invoking a servlet with a URL in a proxy server environment.
I have a MyApp.war file that has the following structure:
dir1/*.jsp
dir2/*.jsp
index.jsp
My web.xml file contains the following:
<servlet>
<servlet-name>ToolA</servlet-name>
<servlet-class>some class also in the .war file</servlet-class>
</servlet>
<servlet-name>ToolA</servlet-name>
<url-pattern>/dir1</url-pattern>
</servlet-mapping>
Note that there is no servlet mapping to /dir2.
Finally, index.jsp contains:
<%
response.sendRedirect("/MyApp/dir1");
%>
Under normal circumstances, the following occurs if I enter the specific URLs in a web browser:
1. http://<server>/MyApp/dir1 --> redirects the request to servlet ToolA
2. http://<server>/MyApp/dir2/some.jsp --> directs the request to dir2/some.jsp
3. http://<server>/MyApp --> (a shortcut URL for /MyApp/dir1) the web container by default directs the request to index.jsp which redirects the request to /MyApp/dir1 which redirects the request to servlet ToolA
This works as intended. My problem arises when I try and invoke my application and a proxy server is in the middle. The first two URL requests work fine. The third presents me with a blank screen. If I click the refresh button on my web browser, my screen appears. The only other bit of information that I know of is when the third URL is entered, the proxy log shows two URLs...(a) http://<server>/MyApp and (b) http://<server>/MyApp/index.jsp.
I have tried adding the following servlet mapping to my web.xml file:
<servlet-mapping>
<servlet-name>ToolA</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Unfortunately, this causes the second URL to break (.../dir2/some.jsp). Any request for a jsp in dir2 fails because I guess, it matches the request against the servlet mapping for "/" and redirects the request to the ToolA servlet.
I do not know if there is a way around this or not. Any help is greatly appreciated.
Have a great day!
- Kelly
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem Invoking Servlet thru Proxy Server