aspose file tools*
The moose likes Servlets and the fly likes Please help with web.xml problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Please help with web.xml problem" Watch "Please help with web.xml problem" New topic
Author

Please help with web.xml problem

Bell Katapa
Ranch Hand

Joined: Jan 06, 2012
Posts: 57

Hello Ranchers,

I have run into a brick-wall and i don't seem to make any meaningful progress at all. My problem is a DD.
I have a servlet called "OnusReportServlet" saved in the path "WEB-INF/classes/reports/servlets".
The package declaration at the very top of the servlet source code is "package reports.servlets;".
The problem is when invoke the servlet using url "/onus.rpt" am getting "HTTP Status 404 - /onus.rpt" message.
The actual line of html code invoking the servlet is:
"<form name="reportForm" action="/onus.rpt" method="get">"

Here below is an excerpt from the DD. Please Help. What am i doing wrong?

<servlet>
<description></description>
<display-name></display-name>
<servlet-name>DownloadServlet</servlet-name>
<servlet-class>reports.servlets.DownloadServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>Onus</servlet-name>
<servlet-class>reports.servlets.OnusReportServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>DownloadServlet</servlet-name>
<url-pattern>/reports.download</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>Onus</servlet-name>
<url-pattern>/onus.rpt</url-pattern>
</servlet-mapping>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

See the ServletsFaq for an entry on troubleshooting this issue.

Your form action looks very suspect.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Bell,

Replace action="/onus.rpt" with action="onus.rpt" this will work.

Regards
Jatan bhavsar

Bell Katapa
Ranch Hand

Joined: Jan 06, 2012
Posts: 57

Hey thanks,

The problem indeed was the form action. I removed the forward slash and it's now working.
Thanks guys,

Bell.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

While that may have worked, it is not the correct solution. Page-relative actions are fragile and may stop working when minor changes are made elsewhere in the web app.

Action URLs, as well as URLs to resources such as images, should be server-relative URLs that begin with the context path.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help with web.xml problem