aspose file tools*
The moose likes Servlets and the fly likes exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "exception handling" Watch "exception handling" New topic
Author

exception handling

shwetha raghavachar
Greenhorn

Joined: Aug 01, 2011
Posts: 14
Hi, i wrote one html file to accept number when i submit it ll go to servlet. The servlet class doestnt handle exception there.
when i enter real value i should get error page which is html.
the error code is written in web.xml.

Am new to this can anyone help me how to resolve.
Here is the code



BadServlet.java



BadNumber.html



web.xml



this has been written after <welcome-file-list> in web.xml


Thanks,

Edited to add code tags - MAB
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1400
    
    6

Could you please paste your code inside code tags, it will be easier for us to read and understand.


Swastik
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1400
    
    6

You just need some change in your servlet code
shwetha raghavachar
Greenhorn

Joined: Aug 01, 2011
Posts: 14
Hi,
thanks for reply...
when i handle exception in servlet i get the error like

[/code]


can anyone tell me the reason.
Thanks,
shwetha
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

first, do you want to redirect to error page when the exception occured in servlet right? then remove try catch in your servlet.
second, read this

if you get any problem, let us know
shwetha raghavachar
Greenhorn

Joined: Aug 01, 2011
Posts: 14
Hi, thanks for reply

ya i need to redirect to error page. But without removing try catch block am getting the error page now just by unchecking
the show friendly http error message in tools option. If we want to redirect to error page doing this change is mandatory or what?
I would like to know the reason here.

Thanks,
shwetha
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

shwetha raghavachar wrote:But without removing try catch block am getting the error page now just by unchecking
the show friendly http error message in tools option.

you might be thrown NumberFormatException from catch block.
shwetha raghavachar wrote:
If we want to redirect to error page doing this change is mandatory or what?
I would like to know the reason here.

http://support.microsoft.com/kb/294807

<edit>corrected a typo</edit>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception handling
 
Similar Threads
url not supported
JSP Bean,not able to work my first bean
Unable to get property values using jsp:getProperty
retreiving all rows from a mysql table to a jsp page
How to call a servlet from a html