title: JSP - how to create a link from a jsp page to another jsp page
body: <p>I am new at JSP. And I know this is the basic question. But I could not do it. What I want is to create a link in this jsp page. However the other page will be different based on login. If it is correct, a link to correct.jsp must be shown, if login is not correct, a link to login.jsp must be shown. </p>
  
  <pre><code>&lt;%
      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";
          }
      }
  %&gt;
  
  &lt;a href=str&gt; &lt;% str; &amp;&gt; &lt;/a&gt;
  </code></pre>
  
  <p>However when I do this, the error of "insert "AssignmentOperator Expression" to complete Expression" for &lt;% str; &amp;> is given.</p>
  
  <p>Thanks,</p>