Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help with web.xml problem

 
Bell Katapa
Ranch Hand
Posts: 57
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the ServletsFaq for an entry on troubleshooting this issue.

Your form action looks very suspect.
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bell,

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

Regards
Jatan bhavsar

 
Bell Katapa
Ranch Hand
Posts: 57
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic