• 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

doubt in error handling in web.xml file

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

we have <error-page> atribute in web.xml file in file i have set up
<error-page>
<error-code>404></error-code>
<location>/pagenot found.jsp</location>
</error-page>

it works fine for when i get 404 error it directs me to this jsp.but i have one problem in the web.xml i have mapping like this

<servlet>
<servlet-name>action</servlet>
<servlet-class>org.apache.struts.ActionServlet</servlet-class>
<servlet>

<servlet-mapping>
<servlet-name>action</servlet>
<servlet-class>*.jhtml</servlet-class>
<servlet-mapping>

in my browser when i call /i.jhtml where the file i.jhtml is not actually present it should display page not found.jsp file instead of this it displays a blank page on the browser. how can i solve this problem.

i think it is able to find valid mapping in *.jhtml web.xml specified above because of this reason it is displaying blank page instead of pagenotfound.jsp but if say like i.jtml then it displays pagenotfound.jsp but i want this page to be displayed even when i call i.jhtml wher the file i.jhtml is not existing. can any body help me in solving this issue.

Thanks
[ March 02, 2008: Message edited by: raja ram ]
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi raja !!!

You are using the Struts framework.
In your webapp, all the requests with the extension ".jhtml" will be managed
by the struts's Controller (org.apache.struts.ActionServlet).

That Servlet looks for valid mappings not in web.xml, but in a file generally called struts-config.xml
If the mapping is not in the config'file, you will have a blank page.

When you are using Struts, the <error-page> won't get processed.
You need to specify the error page redirection in struts-config.xml
You can put it in <global-exceptions> in struts-config.xml
You could configure it for java.lang.Exception. The 404 - Page not found would also be handled.

Make sure your config'file configured in web.xml :

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>



Hope it help.
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply can any one please let me know how to use <global-exceptions> in struts-config.xml with some example code

Thanks
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raja ram:
Hi,

Thanks for the reply can any one please let me know how to use <global-exceptions> in struts-config.xml with some example code

Thanks



In struts-config.xml, we declare <global-exceptions> in the following format:



Here we are declaring that any Action (or business logic) that throws the SystemException will be sent to systemError.jsp. We are associating the error.system.crash message string from our SystemResource file with this exception.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic