Share on Google+Share on Google+

Bipin Kumar Aryan
new 2
0 Answer(s)      3 years and 10 months ago
Posted in : JSP-Servlet
<[email protected] import="java.util.ArrayList"%>
<[email protected] contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
   <% 
 ArrayList<String> arr1=(ArrayList<String>)request.getAttribute("fname");
 ArrayList<String> arr2=(ArrayList<String>)request.getAttribute("email");
%>
<html>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <table>

         <% for(int i=0;i<arr1.size();i++){ %>  
        <tr>   
        <td>
            <%=arr1.get(i)%>
        </td>
        <td>
            <%=arr2.get(i)%>
        </td>
        </tr>
        <%}%>
    </table>
</html>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
sevelet
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author ignite084
 */
public class TestRadioServlate 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();
        HttpSession session=request.getSession(true);
        try {
            String uname="Arati";
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/Exit", "root", "root");
            Statement stmt=con.createStatement();
            ResultSet rs=stmt.executeQuery("Select * from register");
            System.out.println("Select * from register ");
            RequestDispatcher rsd=request.getRequestDispatcher("newjsp.jsp");
            ArrayList<String> arr1=new ArrayList<String>();
             ArrayList<String> arr2=new ArrayList<String>();
            while(rs.next())
            {
//                request.setAttribute("fname", rs.getString(1));
//                request.setAttribute("email", rs.getString(2));
                arr1.add(rs.getString(1));
                arr2.add(rs.getString(2));

            }
            request.setAttribute("fname", arr1);
            request.setAttribute("email", arr2);
            rsd.forward(request, response);
        } 
        catch(Exception e)
        {
            e.printStackTrace();
        }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 {
        processRequest(request, response);
    }

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

Ads

View Answers









Related Tutorials/Questions & Answers:
new 2
new 2  <[email protected] import="java.util.ArrayList"%> <[email protected]..; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 sevelet @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@2 import java.io.IOException; import java.io.PrintWriter; import
new
new    hi i am jane pls explain the difference between string greeting = good morning string greeting = new string ("good morning
Advertisements
new
new  hi the difference between string sname = good morning string sname =new("good morning
new
new    hi i am jane pls explain the difference between heap memory and stack memory
new
new   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <[email protected] contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <...="submit"><br><br><br> <table border="2">
Introduction to Struts 2
Introduction to Struts 2       This section provides you a quick introduction to Struts 2 framework. This section we are discussing the new features, struts 2 basics and architecture
New to struts2
New to struts2   Please let me know the link where to start for struts 2 beginners   Struts 2 Tutorials
Struts 2 version 2.3.16.3 released
Struts 2 version 2.3.16.3 released - Here is the latest maven dependencies code Latest version of Struts 2: Struts 2 version 2.3.16.3 released... for manipulating the Struts Intervals. So, application developed in Struts 2 should
Magicbox 2
Magicbox 2  how to build this? import java.util.*; class magicbox{ public static void main(String args[]){ Random r=new Random(); int[][] magic=new int[3][3]; int temp=r.nextInt(9)+1; boolean
Struts 2 Tutorial
Struts 2 Tutorial       RoseIndia Struts 2 Tutorial and Online free training helps you learn new elegant... 2 The new version Struts 2.0 is a combination of the Sturts action framework
Struts 2
Struts 2   I am just new to struts 2 and need to do the task. I have a requirement like this : when i click on link like Customer , this will display all the customers , address from a database table using jdbc and the screen
use is of 2
use is of 2  why we use 2 in "Integer.parseInt(str,2);" for binary to decimal conversion..??   ya i got it... because binary contain only two o and 1...so here use 2...same as octal has 8
Struts 2
Struts 2  we can extend DispatchAction class to implement a common session validation in struts 1.x. how to do the same in the struts2
Struts 2
Struts 2  I am getting the following error.pls help me out. The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has
New to struts2.0
New to struts2.0  hi am new to struts2.0 in my application i have declared a list in static how to get the static list values in my result.jsp??? if i remove the static in the list the result is getting displayed.why
Thunderbird 2
Information Organized Thunderbird 2 features many new enhancements to help...Thunderbird 2       Mozilla?s Thunderbird 2 email application is more powerful than ever. It?s now
Echo 2
Echo 2       Echo 2 allows you to code Ajax apps in pure Java (Demo)which automatically generates HTML and Javascript. Read full Description
New to Java - New to java tutorial
. Properties props = new Properties(); // code to fill props with any... a unique session by getInstance() method… Properties props = new Properties... will use subclass javax.mail.internet.MimeMessage. MimeMessage message = new
FireFox 2
FireFox 2       The award... to do on the Web, and Firefox 2 is full of helpful features to make your... Add-ons that enhance Firefox. It?s easy to personalize Firefox 2
What is Struts 2 framework
What is Struts 2 framework  Hi, I am new to the Java web programming. I have completed JSP, Servlet and HTML. Now I want to learn Struts 2. Tell me what is Struts 2? Thanks
Web 2
Web 2.0 Introduction Web 2.0, a phrase is a cluster term for the new phase..., and an attempt to understand the rules for success on that new platform?. So Web 2.0 is a new way of business via Internet. It?s really a new business tactic
Web 2
computing. Though, it is not a new concept for the Internet, but in Web 2.0.... With the evolution of new century, the Web became much more interactive. It allowed... of Web 2.0 in 2004 in a conference claiming the new version of Web. It began
Web 2
applications The new feature included in the Web 2.0 based application in which... technologies are new and evolving techniques for learning language, but new added features
Web 2
2.0 tools are endless even though we can say that the new generation of Internet
Web 2
. Descriptive list of Web 2.0 tools are endless even though we can say that the new
Struts 2 - Beganner
Struts 2 - Beganner  Hi ! I am new to Struts2 and I need clarification over Difference between Action Proxy and Action Mapper in struts2 and When both perform their activity?????? Many Thanks Venkateshlu
zend framework 2
zend framework 2  i am new in zf2 and i want to develop a website in zf2 so can anyone help me to figure out the(login and signup page) with database
Maven 2 - Maven
Maven 2   Hi, I m new to Maven 2 and in process to implement Maven2. I have browse in the net and got my Maven 2 installed but now I m facing few concerns on creating a small project. Please help me in this regard Thanks
session maintain in struts 2
session maintain in struts 2  hi i am new to Struts 2..... in Action class i wrote **HttpSession session = request.getSession(); session.setAttribute("name", name1);** but in jsp class String session_name=(String
Pagination in struts 2
Pagination in struts 2  Hi, I have one question regarding pagination in struts 2 I saw one of your code that you explain here:- http... me or guide me what other option i have to use pagination in struts 2 without
help me 2
help me 2  write java program to enter five numbers and will determine the location of the number sample output: ENTER 5 NUMBERS: 1 2 3 4...) { Scanner input=new Scanner(System.in); int array[]=new int[5
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads