How can I pass a string to another jsp page? What's wrong in mysql query to select a table, String query ="select * from " + table + ""; : Why mysql query string query ="select * from " + table + "";` is not working the table name is coming from another jsp page.

And why session. setAttribute ("", "table");` is not working to import string from jsp to jsp?

I have two jsp file in my code one is for selection of table for username and password to get login the file name is statement.jsp and other file statement is for showing data in a table that is selected in statement3.jsp. I want to use table string in another jsp page to show that table.
           
**error**

       String query ="select * from " + table + ""; //for selection of table

       session.setAttribute("", "table");  //To pass String table from statement.jsp to statement3.jsp to show table. 

**[![enter image description here][1]][1]statement3.jsp**    

      <%  
         ResultSet rs = null;
         session.setAttribute("", "table"); 
           
         String query ="select * from " + table + "";
          
         rs=st.executeQuery(query);
     %> 
    
-------------------------------------     
**statement.jsp**     
  
    <% 
     ResultSet rs = null;
     String name=request.getParameter("username");
     String abc=request.getParameter("password");       
    
     String gender = request.getParameter("gender");
          
     if (gender != null) {
     String table = gender.equals("teacher") ? "teacher2" : "student";
 
     out.println(table);  
    
     String query ="select * from " + table + " where username='"+name+"' AND password='"+abc+"'";
     rs=st.executeQuery(query); 
     out.println(rs);
     if(rs.next()) 
     {
       response.sendRedirect("statement3.jsp");
     }
       else
    {
      response.sendRedirect("index.jsp");
     }}
    %>


`Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:729)`
  [1]: http://i.stack.imgur.com/1zAt8.jpg