cancel
Showing results for 
Search instead for 
Did you mean: 

Catching Web Service Error in JSP

Former Member
0 Kudos

I have a JSP page that consumes a webservice. The JSP page mostly consist of HTML tags and some java codes (for consuming web service). If my web service fails for some reason, I want the page to still show an page that still works (without the error report). That page will not contain my code for consuming web service. Can I do this using just try catch block?

e.g.


<% try{
//connection to web service
%>
<h1>
<%
String var1 = getMethod("1","1");
out.write(var1); //will output Hello
%>
</h1>

<%
}catch (Exception e){
<h1>Hello</h1> <!--my original html page-->
}
%>

This will not work right? Cause you need to have a pure java code inside try catch block. Is there any other way to catch the web service error and still output my original page? Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Looks like I can somehow catch some errors using try catch. I just need to print all my HTML tags in the try catch. My problem know is I can only catch errors in web service lookup. Still can't catch 500 internal server error (Error compiling) and 500 internal server error (error parsing). Is there a way to catch these errors and print a custom error message?