I am grabbing some data from a page using the code below:
int clientId = Integer.parseInt(request.getParameter("clientId"));
I have tried surrounding it with try/catch and then redirecting in the catch block using response.sendRedirect("page.jsp"); but the page does not re-direct, it seems to want to finish the whole script (which in turn throws more errors because the initial variables aren’t valid!). Am I missing something basic here?
You are perhaps missing a
returnstatement (although I don’t see your code):If you simply call
sendRedirect(..)this will set theLocationhttp header, and an http status, but will not affect the flow of the current method, and it will continue.