title: Passing parameter values using a href, storing and retrieving them using session only with JSP's
body: <p>As opposed to what my question suggests, I completely understand that it is not right to have any form of code in a JSP. But I have an important task to accomplish and this is the scenario : 
      Once a link is clicked, the parameters that are passed, whatever it may be, is being truncated (due to security reasons) and I need to obtain these parameters somehow  after a user has logged in. I am trying to do this using a session.</p>
  
  <p>I have four JSP pages say :</p>
  
  <ol>
  <li>routing.jsp</li>
  <li>intermediateTarget.jsp</li>
  <li>login.jsp</li>
  <li>target.jsp</li>
  </ol>
  
  <p>and page with a link and some parameters being passed into it : </p>
  
  <pre><code>&lt; a href="router.jsp?p1=s&amp;p2=s123"&gt;Click here&lt;/a&gt;
  </code></pre>
  
  <p>Once I click this it takes me to <code>router.jsp</code> where I create a session and obtain the passed parameters and also set them into the session:</p>
  
  <pre><code>&lt;% String param1 = request.getParameter("p1");
     String param2 = request.getParameter("p2");
  
     HttpSession session1 = request.getSession(true);
     session1.setAttribute("p1", param1);
     session1.setAttribute("p2", param2);
     response.sendRedirect("intermediateTarget.jsp");
   %&gt;
  </code></pre>
  
  <p><code>router.jsp</code> is executed <code>onload</code> so it is basically re-directed to <code>intermediateTarget.jsp</code>.</p>
  
  <p>Here, I am obtaining the parameters using getAttribute :</p>
  
  <pre><code>    HttpSession session1 = request.getSession();
      String param1 = (String) request.getAttribute("p1");
      String param2 = (String) request.getAttribute("p2");
  
      String param = request.getParameter("param");
      String lgn = request.getParameter("lgn");
  
      if (null != param) {
          response.sendRedirect("empLogin.jsp");
      } else if (null != lgn) {
          response.sendRedirect("target.jsp");
      }
  </code></pre>
  
  <p>I have two hidden parameters being passed from the login page and the routing page which are <code>lgn</code> and <code>param</code> respectively. After checking which ever page the request is gotten from, I would need to redirect it to a <code>target.jsp</code> or <code>login.jsp</code>.   </p>
  
  <p>Basically, after logging in I need to be just able to obtain the same parameters from the session and display it on the target page (like a confirmation that I am in fact able to obtain the parameters that I passed in the link.)</p>
  
  <p>Again, I don't need servlets because this is something that we need to include from our end using only JSP's. </p>
  
  <p>Also, I have read on trying to extract the part of the URL after the <code>?</code> and even went into the concept of extracting deeplinks but I'm not getting anywhere.</p>
  
  <p>Sorry if the post seems too long. Just wanted to give a clear idea of my situation and also any other ideas on this would be greatly appreciated.</p>
  
  <p>Thanks a lot in advance !</p>