help on controller jsp

I have some problems with passing control between jsp pages. Was trying out a controller page.What i have come up with. testcontroller.jsp page will haf a hyperlink n a session attribute passed to test1.jsp. When the user clicks on the hyperlink, it is supposed to go to test1.jsp. on test1.jsp, i have included the page scontroller.jsp. in scontroller.jsp, it is supposed to test whether the session attribute exists. If it is null, the page will be redirected to another page called index.jsp(instead of showing the page test1.jsp) the main problem is when a user clicks on a hyperlink for eg test.jsp, on test.jsp itself, unless the user is identified, the page will not be shown to the user. that is y i have come up with the code though i think somehow the passing and checking of session attribute is unsuccessful. thank you for helping=) below is the code for testcontroller.jsp <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <% session.setAttribute("allowUserId","");%> <a href="test1.jsp">click here</a> </body> </html> here is the code for scontroller.jsp <%@ page language = "java" import = "java.sql.*" import = "java.lang.*","java.sql.*" import="javax.servlet.http.HttpSession.*"%> <jsp:useBean id = "db" class = "javabeans.DbAccess" scope = "session" /> <%-- check to see if user has logged in yet note: login is not part of this application, so user is redirected to the login application --%> <% if (((String)session.getAttribute("allowUserId")) == null) { %> <jsp aram name="action" value="failed" /> <jsp:forward url="index.jsp" /> <% } %>

in testcontroller.jsp, why not have the href point directly at scontroller.jsp directly (instead of including scontroller in test1.jsp). Are you using a web.xml file? If you are you can define a default page under the "welcome-file-list" attribute. <!-- *** in testcontroller.jsp *** -->

<!-- *** web.xml *** -->

In your scontroller.jsp:

If you choose to do it this way, you won't need to include scontroller in test1.jsp. I also noticed in your original code that you didn't use the <jsp aram> tag correctly. The param tag is a sub tag, so it needs to be surrounded by <jsp:include></jsp:include> or <jsp:forward></jsp:forward> or whatever other JSP tags support it.