File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception handling

 
shwetha raghavachar
Greenhorn
Posts: 14
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1601
5
Android Java Java ME
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please paste your code inside code tags, it will be easier for us to read and understand.
 
Swastik Dey
Rancher
Posts: 1601
5
Android Java Java ME
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just need some change in your servlet code
 
shwetha raghavachar
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic