title: How to put value in textbox getting as a parameter in request object
body: <p>I have a textbox whose value I want to set with the value I get as a parameter in the request from user. </p>
  
  <p>For example, the request is :
  localhost:8084/quiz/login.jsp?uname=manish
  I want to display "manish" in the textbox in the form.</p>
  
  <p>How can I do that?
  Here is the full code of my login.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Login Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;%
      String error=(String)request.getParameter("error");
      String uname=request.getParameter("uname");
      if(error!=null)
      {
          if(error.equalsIgnoreCase("no_username_password"))
              out.println("Username and password can't be empty");
          if(error.equalsIgnoreCase("no_username"))
              out.println("Username is required");
          if(error.equalsIgnoreCase("no_password"))
              out.println("Password is required");
      }
  %&gt;
  
  &lt;form method="post"  action="LoginServlet"&gt;
  UserName: &lt;input name="Username"&gt;&lt;br&gt;
  Password: &lt;input name="password"&gt;&lt;br&gt;
  &lt;input type="submit"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the code of my servlet </p>
  
  <pre><code>package com.util.Servlets;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.RequestDispatcher;
  import javax.servlet.ServletException;
  import javax.servlet.annotation.WebServlet;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import javax.servlet.http.HttpSession;
  
  /**
   * Servlet implementation class LoginServlet
   */
  @WebServlet(description = "Will take username and password from login.html and validate user", urlPatterns = { "/LoginServlet" })
  public class LoginServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          String username=request.getParameter("Username");
          String password=request.getParameter("password");
          //PrintWriter out=response.getWriter();
          //System.out.println(request.getAttribute("Error"));
          //HttpSession session=request.getSession();
          if((username=="" || username==null)&amp;&amp;(password=="" || password==null) )
          {
              response.sendRedirect("Login.jsp?error=no_username_password");
          }
          else if((username=="" || username==null)&amp;&amp;(password!=""||password!=null))
          {
              response.sendRedirect("Login.jsp?error=no_username");
          }
          else if((username!="" || username!=null)&amp;&amp;(password==""||password==null))
          {
              String url="Login.jsp?error=no_password&amp;uname="+username;
              response.sendRedirect(url);
          }
      }
  
  }
  </code></pre>