• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

exception handling  RSS feed

 
Greenhorn
Posts: 14
  • Likes 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
 
Rancher
Posts: 1878
15
Android Eclipse IDE Java Java ME
  • 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: 1878
15
Android Eclipse IDE Java Java ME
  • Likes 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
  • 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
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 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
  • 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
  • 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>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!