Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, 16 December 2012

HOW TO PASS PARAMETERS FROM JSP TO SERVLET?

    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:
               <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script language="javascript">
          
        </script>
    </head>
    <body>
        <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">
          </form>
      
    </body>
</html>
servlet code:
public class jdbcservlet extends HttpServlet {

      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        out.println(getServletConfig().getInitParameter("email"));
         String f_name,l_name,m_no;
        f_name=request.getParameter("first name");
        l_name=request.getParameter("last name");
        m_no=request.getParameter("mob_no");
        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....

Wednesday, 5 December 2012

DIFFERENCE BETWEEN SWING AND AWT

        Hello friends after a long time osWorld is come back with some java concepts.Today i am going to tell you about swing and also explain basic difference between swing and abstract window toolkit(awt).
        Swing is fully featured user interface development kit for java applications.It is foundation of sun's java classes(jfc).It provides rich components of gui.It provides list control,table control,tree controls,buttons,and labels and also some another features.Java swing is also referred as java GUI(Graphical user Interface) Widget toolkit.Now let us see basic difference between java swing and awt(abstract window toolkit)

DIFFERENCE BETWEEN JAVA SWING AND AWT

AWT:-
              -It uses peer components of operating system
              -It is platform dependent thus as per operating system it looks differ.
              -It is heavy weight component 
              -It not provides pluggable look and feel
              -we must have to write a code for awt

SWING :-
               -Swing is platform independent Thus display management is same in different perating       
                 systems.
               -It is lightweight component
               -It provides pluggable look and feel.
              
        So friends this is basic concepts of Swing and Awt.for more concepts and practical examples of java stay in touch.If you have any quqry then mention in comments.Have a nice day.....
Related Posts Plugin for WordPress, Blogger...