Help! I need an error page in JSP.

M

Mohammed Mazid

Hi folks!

For those of you who are an expert in JSP, I am using Dreamweaver
developing a website on "Tourist Attractions". I have implemented a
search page, but if nothing is found in my database, then I need to
direct to the page where it should say "Search not found". Well, a
search term not found.

Assume that the error page is error.jsp.

Can anyone please complete the code for me?

Much appreciated
 
R

Rob

Is this what you have in mind??

if (noSearchResultsFound) {
response.sendRedirect(response.encodeRedirectUrl("/error.jsp"));
return; // returns out of the compiled jspService() method
}

This is assuming that you are directing the user from the search results
jsp -- if the code actually resided in a servlet, it would be different (in
which case, you could use the
getServletContext().getRequestDispatcher().forward() method).

Hope this helps,
Rob
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top