I am in the process of writing an application that does various database actions. I currently have a Java class that handles all my database actions and a JSP page that will present the data. I'm trying to figure out how to redirect to a different URL based on what has happened on the previous screen. For instance, I have login screen, the login then calls a method of my database class to verify the user, it will return a boolean true/false to indicate whether permissions are valid. If the permissions are not valid, I want to redirect the user to an error page. If the permissions are valid, I want to continue on with the processing of the current jsp page. I currently am only using scriptlets of Java and have not intended to use Servlets. Is this possible within the <% %> context of the jps scriptlet? In ASP I would do a response.redirect "URL". I have seen mention of a response.sendRedirect("URL"), but when I try to use that, it doesn't recognize response. Any ideas?
I have used the reponse.senRedirect() and it has worked so I don't know what you are doing wrong (maybe you could ellaborate with code and error mesg?) One thing to keep in mind is that if any of the response buffer has been committed, you get an illegel StateException ( once the buffer hhas been filled and sent to the client, you can't user response.sendRedirect()). You might try using: instead hope this helps paul
Thanks guys. I'm not sure exactly what I was doing wrong. It works fine now. The only thing that I know has changed is that I moved the function from a <%! %> declaration to just straight inline code in the <% scriptlet %>. Thanks for you replies. Jason.