I am new to JSP. And I know this is the main question. But I could not do it. I want to create a link on this jsp page. However, another page will be different based on login. If this is correct, you must provide a link to correct.jsp, if the login is incorrect, a link to login.jsp should be shown.
<% String str = ""; String userid = request.getParameter("usr"); session.putValue("userid", userid); String pwd = request.getParameter("pwd"); Class.forName("com.mysql.jdbc.Driver"); java.sql.Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/pr", "root", "xxx"); Statement st = con.createStatement(); ResultSet rs = st .executeQuery("select * from a where name='"+ userid + "'"); if (rs.next()) { if (rs.getString(2).equals(pwd)) { out.println("welcome " + userid); str = "correct.jsp"; } else { out.println("Invalid password try again"); str = "login.jsp"; } } %> <a href=str> <% str; &> </a>
However, when I do this, the error is "insert" AssignmentOperator Expression "to complete the expression" for <% str; &>.
Thanks,
source share