Sunday, 16 December 2012


    Hello friends today i am going to post about pass parameters from jsp to servlet.For pass a parameters we must have to follow the bellow code.

jsp code:
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script language="javascript">
        <form action="jdbcservlet" method="post">    
            <label>first name</label>&nbsp;<input type="text" name="first"><br>
            <label>last name</label>&nbsp;<input type="text" name="last"><br>
            <label>mobile no</label>&nbsp;<input type="text" name="mob_no"><br>
            <input type="submit" value="submit">
               <input type="reset" value="reset">
servlet code:
public class jdbcservlet extends HttpServlet {

      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
         String f_name,l_name,m_no;
        f_name=request.getParameter("first name");
        l_name=request.getParameter("last name");
        out.println("first name is: "+f_name);
       out.println("last name is: "+l_name);
       out.println("mobile no is: "+m_no);
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);

    By using this code you are able to pass the parameters from jsp to servlet.Here for that we have used action property in form tag which shows where to transfer the control after click the submit type button.And method shows the by which method parameters will pass.get and post these two methods are available.
     If you face any problem in implementation in this code then mention in comment and feel free to ask any question related to java.Have a nice day....


  1. I am basically not a programmer and I am comparatively new to Java technology , so I was wondering what all topics should be covered up if i have to start java from the start and has any one
    studied or got any info regarding this 6 week java training online course and should we also have knowledge of C language before we further move on to Advance Java topics??

  2. before move to advanced java you must know core java concepts..and you must have knowledge of c language.because without c you are not able to understand core java.if you are not aware of c language then i advised you to start from c language first after that java becomes more easier for you.


Related Posts Plugin for WordPress, Blogger...