VB/asp -> java/jsp, error handling?

J

JGH

I'm trying to convert a VB/asp application to java/jsp. I'm kind of new
to java/jsp.

The app allows a user to enter an id which is looked up in a database.
This is not for authentication. It's just to fill in some default
values. My problem is what to do if the lookup fails. Is there a right
way to handle this in java/jsp? Via Exceptions and an error page,
perhaps?

In the VB app, when the user clicks the submit button, the script calls
itself, tries to look up the id and if it fails, it does a
Response.Redirect back to itself again this time with an error code.
Maybe I should just do the same thing in jsp.

The VB code is something like this:

<%
myScript = request.servervariables("script_name")

userid = Request.QueryString("userid")
If (Not lookup (userid)) Then
Response.Redirect (myScript & "?ERROR=1")
End If

myError = Request.QueryString("ERROR")
If (myError = "1") Then
Response.Write ("Invalid ID, please try again")
End If
%>



<FORM action="<% =myScript %>" method="POST">
<INPUT name="userid" type=text">
</FORM>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top