Share on Google+Share on Google+

Bipin Kumar Aryan
mew 333
0 Answer(s)      3 years and 10 months ago
Posted in : Ajax
 print("code 
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


<[email protected] contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Location</title>
    </head>
    <body>
        <h1>Fill Up Your Details</h1>

    <center>  <form action="hit" method="POST">
            <fieldset>

                <b> iGnite Id:</b><input type="text" name="id" placeholder="Ignite Id"><br><br>
                <b>Your Name:</b><input type="text" name="name" placeholder="Name"><br><br>
               <b> Home Town:</b><input type="text" name="home" placeholder="Home"><br><br>
                <b>Location:</b><input type="text" name="location" placeholder="Location"><br><br>
                <b>Gender</b><input type="radio" name="sex" value="male">Male
                            <input type="radio" name="sex" value="female">Female<br><br>

                <b>Choice</b><input type="checkbox" name="choice" value="Kolkata">Kolkata
                            <input type="checkbox" name="choice" value="Chennai">Chennai
                            <input type="checkbox" name="choice" value="Mumbai">Mumbai
                            <input type="checkbox" name="choice" value="Delhi">Delhi<br>
                            <input type="submit" name="submit" value="Submit">

            </fieldset>
            <center><a href="view.jsp"><h1>VIEW</h1></a></center>



        </form></center>
    </body>
</html>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
<[email protected] import="java.sql.Statement"%>
<[email protected] import="java.sql.DriverManager"%>
<[email protected] import="java.sql.Connection"%>
<[email protected] import="java.sql.ResultSet"%>
<[email protected] contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
    <center> <h1>View Your Location</h1>
        <form action="view" method="POST">
            <b> Enter Your Ignite Id:</b><input type="text" name="id" placeholder="IgniteId"><br><br>
            <input type="submit" value="SUBMIT" name="submit"><br><br><br>
            <table border="2">

                <th>Name</th>
                <th>home</th>
                <th>Location</th>
                <%
                    try {

                        ResultSet rs = (ResultSet) request.getAttribute("data");
                        while (rs.next()) {
                %>                                              
                <tr>
                    <td><input type="text" value="<%=rs.getString("name")%>"</td>
                    <td><input type="text" value="<%=rs.getString("home")%>"</td>
                    <td><input type="text" value="<%=rs.getString("location")%>"</td>
                </tr>
                <%                        }
                    } catch (Exception e) {
                    }
                %>

            </table>

        </form> </center> </body>
</html>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
insert int data base
@@@@@@@@@
import com.mysql.jdbc.PreparedStatement;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author ignite178
 */
public class hit extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /*
             * TODO output your page here. You may use following sample code.
             */
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet hit</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet hit at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out=response.getWriter();
        String Id=request.getParameter("id");
        String Name=request.getParameter("name");
        String Home=request.getParameter("home");
        String Location=request.getParameter("location");
        String Gender=request.getParameter("sex");
        String Choice=request.getParameter("choice");

        try{
         Class.forName("com.mysql.jdbc.Driver");
         Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/location", "root", "root");
        String sql="INSERT INTO posting (ignite_id,name,home,location,gender,choice) VALUES('"+Id+"','"+Name+"','"+Home+"','"+Location+"','"+Gender+"','"+Choice+"')";
      PreparedStatement ps=(PreparedStatement) con.prepareStatement(sql);
        ps.executeUpdate();
        ps.close();
        con.close();



        }
        catch(Exception e)
        {
            out.print(e.toString());
        }
        finally{
            out.print("Submit Successfully");
        out.close();

        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@222
how to fetch
@@@@@@@@@@@@@@@
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.ResultSet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author ignite178
 */
public class view extends HttpServlet {
    private ServletResponse response;

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /*
             * TODO output your page here. You may use following sample code.
             */
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet hit</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet hit at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
//        try {
//            try {
//                Class.forName("com.mysql.jdbc.Driver").newInstance();
//            } catch (InstantiationException ex) {
//                Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//            } catch (IllegalAccessException ex) {
//                Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        } catch (ClassNotFoundException ex) {
//            Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        Connection con = null;
//        try {
//            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/location", "root", "root");
//        } catch (SQLException ex) {
//            Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        String id=request.getParameter("id");
//        String query = "select * from posting where ignite_id='"+id+"'";
//        Statement s = null;
//        try {
//            s = con.createStatement();
//        } catch (SQLException ex) {
//            Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        ResultSet rs = null;
//        try {
//            rs = s.executeQuery(query);
//        } catch (SQLException ex) {
//            Logger.getLogger(view.class.getName()).log(Level.SEVERE, null, ex);
//        }
//        request.setAttribute("data", rs);
//        RequestDispatcher rd = request.getRequestDispatcher("view.jsp");
//        rd.forward(request, response);
//    }
    }
    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String Id = request.getParameter("id");

        try {
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/location", "root", "root");
            String id=request.getParameter("id");
        String query = "select * from posting where ignite_id='"+id+"'";
        Statement s = null;
            s = (Statement) con.createStatement();
            ResultSet rs = null;
             rs = s.executeQuery(query);
              request.setAttribute("data", rs);
        RequestDispatcher rd = request.getRequestDispatcher("view.jsp");
        rd.forward(request, response);              

      } catch (Exception e) {
            out.print(e.toString());
        } finally {

            out.close();

        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}



sample");

Ads

View Answers









Related Tutorials/Questions & Answers:
mew 333
mew 333   print("code @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <[email protected] contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content
loops
loops  I need the program output 55555 4444 333 22 1 like this by using for loop and if condition only
Advertisements
pyramid
pyramid  how to print 1 22 333 4444 55555   class Pyramid { public static void main(String[] args) { for(int i=1;i<...:- 1 22 333 4444 55555
conditions
conditions  hi, i want to get the output in this format 55555 4444 333 22
Java For loop Iterator
Integer(333)); list.add(444); Iterator it = list.iterator... 333 444
Java arraylist remove
 removal of index 2"+list);   } } Output With all element [111, 222, 333, 444] after removal of first index[222, 333, 444] after removal of index 2[222, 333
java
java  hi i need java program to print this : 1 22 333 4444   public class Pattern{ public static void main(String []args){ for(int i=1;i<=4;i++){ for(int j=1;j<=i;j
Java arraylist sort
);   } } Output Withiout sorting [444, 222, 333, 111] After sorting [111, 222, 333, 444
Java Collection : LinkedHashSet Example
;Integer>(); //Adding elements set.add(100); set.add(333); set.add(400... of LinkedHashSet : 4 LinkedHashSet elemnts : [100, 333, 400, 111] After Deletion - Size of LinkedHashSet : 3 LinkedHashSet elemnts : [100, 333, 400
print numbers in traingle shape
print numbers in traingle shape  1 22 333 4444 i want output like this please help me   class Pyramid { public static void main(String[] args) { for(int i=1;i<=4;i++){ for(int j=1;j<
Getting connect error in Jmeter - Development process
) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333
Collection : ArrayList Example
); // Adding elements in ArrayList list.add(333); list.add(400); list.add(200... after adding elements : 4 Elements of ArrayList : 333 999 400 200 Size of ArrayList after removing elements : 3 Elements of ArrayList : 333 999 400
java code to send an email
(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress
jQuery tooltip
:1px solid #333; background:#f7f5d1; padding:2px 5px; color:#333; display:none
Converting java arrays into list
: 4 ccc [aaa, bbb, ccc, ddd] ------------------ 4 333 [111, 222, 333, 444
java.sql.BatchUpdateException: Duplicate entry '135-16448' for key 1 - Hibernate
(SessionImpl.java:333) at org.hibernate.transaction.JDBCTransaction.commit...) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333...) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333
Weblogic8 server problem
:333) at javax.naming.InitialContext.lookup(InitialContext.java:392
java run time error - JDBC
) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333
Encountering error when connecting MSSQL Server 2005 using Hibernate 3.0
) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333
Problem with external DTD - XML
"}; String[] id = {"111","222","333"}; String[] type = {"customer","manager
struts logic:iterate tag
) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333
For Loop in Java
;} } Output of the program :  1 22 333 4444 55555 Download For Loop Example
EXT JS
-col-topic b { color:#333 }) header: 'SELECT
struts jar file problem
(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress
optimze page load - Java Beginners
; color: #333; text-align: left; } #modal_overlay
DOJO xmlStore - Ajax
{ border: 1px solid #333; width: 100em
AJAX Search
-serif; color:#333; padding:5px; margin-bottom:10px; background
myeclipse8.5
) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333
Websphere application error - Hibernate
(WebServicesEngineConfigurationGenerator.java:333) [10/5/10 13:19:40:594 EDT] 00000043 SystemOut O
ProgressBar Control in Flex4
title="ProgressBar Control Example" width="333"
Tutorials   
Java Spring Hibernate Struts Training Ajax java How to cascade two text boxes?? How to create runtime drag and drop form builder using asp.net mvc and jquery jsp+ajax validation JQuery-JSP AJAX example not working What is Ajax Framework How to write first example in Ajax? What are Advantages and Disadvantages of AJAX What is Ajax? how to set running watch with descending order in applycation with ajax how to set running watch with descending order in applycation with ajax jsp pages for dispatchaction for adding user to database c++ new, delete, string class using ajax i want to insert data into oracle database how to generate reports from oracle database using jsp and ajax code dynamic creation of multiple drop-down menus Ajax programming tutorials Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page Displaying data from combobox on the web page What is Java? How to make a ajax application which take data from textarea and that page is not refreshing. how can add new line character into ajax response for java how can add new line character into ajax response for java c# c# asp.net Struts 2 + Ajax bodygaurd java Ajax mew 333 data insertion and fetch 1 my answer what is an ajax call? what is an ajax call? JSF How to easily send and receive recorders from database (in AJAX)? calculating time difference for manually entered in-time and out-time in hours and min for dynamically generated rows in jsp and display in third textfield. how to operate on select box using ajax in struts2? how to operate on select box using ajax in struts2? Auto Search box using ajax Dependant Dropdown Lists AJAX REGISTRATION FORM ajax code for jsp java i want to know how a slide will hide i want to know how a slide will hide

Ads

 
Advertisement null

Ads