title: How to pass a value of a variable from a java class to the jsp page
body: <p>I have 2 files named <code>Admin.java</code> and <code>index.jsp</code>.</p>
  
  <p>In <code>Admin.java</code> through a function I retrieve the value of the varible named <code>res</code>. This variable needs to be passed to a JSP page.  </p>
  
  <p>The <code>Admin.java</code> is in <code>C:\Users\praveen\workspace\SemanticWeb\src\controller</code> whereas the <code>index.jsp</code> is in <code>C:\Users\praveen\workspace\SemanticWeb\WebContent</code>.</p>
  
  <p>The code of <strong>Admin.java</strong> is:</p>
  
  <pre><code>public Admin() 
  {
    super();
  }       
  
    protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException 
   {
  
      if (action.equals("login")) 
      {
          String userName="";
          String password="";
  
          userName = request.getParameter("username");
          password = request.getParameter("password");
  
          response.setCharacterEncoding("UTF-8");
  
          SemanticSearch semsearch = new SemanticSearch(request.getSession());
          semsearch.loadData(REALPATH + RDFDATASOURCEFILE1);
  
          String res=semsearch.searchForUser(userName, password);
          System.out.println("The value of res been passed is "+res);
  
          request.setAttribute("rest", res);
  
          return;
       }
  </code></pre>
  
  <p>The code of <strong>index.jsp</strong> is</p>
  
  <pre><code>function login(user, pass) 
  {
  
    $.ajax({
      type:"GET",
      url: "Admin?action=login",
      dataType: "text",
      data: { username: user, password: pass },
      success: function(response){
  
      }
  </code></pre>
  
  <p>within the </p>
  
  <pre><code>function(response)
  {
   ......
  } 
  </code></pre>
  
  <p>I need to access the value of <code>res</code> passed by <code>Admin.java</code>. I am not able to get any proper help for my code on the Internet. Please can someone help me with this.</p>