Navigate database table in JSP

hi
can anybody help me
i have table in database and i want to read 10 rows from it per one page
by using JSP
this is my code
<H1>The Table of Results</H1>
<%
Connection connection = DriverManager.getConnection(
"jdbc:mysql://localhost/metasearch", "user", "aaa");
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY) ;
ResultSet resultset =
statement.executeQuery("select id,url,summery,title from Links") ;
%>
<table class="style1">
<% while(resultset.next()){ %>
<tr>
<td valign="top"><%= resultset.getString(1) %>-</td>
<td><a href= "<%= resultset.getString(2) %>"><%= resultset.getString(4) %></a><p></p><%= resultset.getString(3) %><p></p><%= resultset.getString(2) %></td>
</tr>
<% } %>
</table>

http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/DEA2eTOC.html

Similar Messages

  • How to display Column Names of a Database Table in JSP

    Dear All,
    I want to display all the attribute names(column names) of a database table on JSP.
    [ ex:  mytable contains : ( EmpId,EmpName,Dept ). This should be display as  EmpId--text box                    
    EmpName--text box
    Dept----textbox
    please note , i don't want to display values,but only column names

    Yeah make use of methods like
    ResultSet DatabaseMetaData.getColumns(String catalog, String schemaPattern, String tableName, String columnNamePattern)
    else use
    String ResultMetaData.getColumnName(int column_index)
    search google i'm sure u wud get thousands of example on it... :)

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Generate jsp from database table

    Does anyone know of a utility that will take a database table as input and generate a generic maintenance app (jsp) that will allow add/change/delete functionality to the table?
    I tried a utility called JSPMaker, however the code generated is horrid and I'm afraid it will not be maintainable.
    I also loaded Workshop Studio and was hoping that the dbXplorer had that functionality, but have not been successful.
    Thanks in advance!
    Rob

    I think the answer for the first question is JSTL. :)

  • Browse and update database tables

    I'm looking for a tool that will let me connect to an Oracle database, select a table and some fields off the table and build a simple java class to navigate / update the data.
    Essentially, I'm looking for a tool that replicates the way Microsoft Access can build a form for navigation and update of a database table.
    However, I want to use java, not MS Access.
    Any ideas if such a tool is available ?
    Thanks

    http://squirrel-sql.sourceforge.net/

  • Deleting a row from a table using jsp

    Given a table in a jsp, can an user click on a row of that table and retrieve the information so that the program can delete a record from a database table?
    most of the tables that I have seen are static, the user cannot interact with them(specially when the user wants to delete several records from a database table).
    Can anyone suggests a good book or way of deleting a row from table using jsp.

    eg use a column in the table that has a radio button or check box,
    on submit, get all the rows that are checked, using the row as an index into your db store, get the key and use the key to issue the sql delete command.

  • How to insert message style text columns in database tables

    Hi All,
    i have two pages.
    in first page segment1 lov is their.once u select the segment1 and click on the create button its navigate to next page.
    and display the releted segment1 details(these columns are message text input fields but read only columns).
    plz help me those columns are insert into database tables.
    its very urgent
    Thanks
    Latha.

    Hi Anil,
    plz help me still i am faceing the problem
    so plz help me because i dont know java.
    i wrote below code and i got the below error.
    if(pageContext.getParameter("Submit")!=null)
    String projnumber=pageContext.getParameter("ProjectNO");
    //String projectnumber=pageContext.getParameter("Projectnumber");
    String oldoperationid=pageContext.getParameter("EmployeeNumber");
    String newManagerName=pageContext.getParameter("NewManagerName");
    String ProjectID=pageContext.getParameter("ProjectID");
    String OldOperationName=pageContext.getParameter("OperationsManager");
    String OldOperationID=pageContext.getParameter("OldOperationID");
    OAMessageTextInputBean projnumberbean =webBean.findIndexedChildRecursive("ProjectNO");
    String projnumber=null;
    if(bean!=null)
    projnumber = (String)projnumberbean.getValue(pageContext);
    Serializable[] params = {projnumber,oldoperationid,newManagerName,ProjectID,OldOperationName,OldOperationID};
    am.invokeMethod("xxinsertpagelogic",params);
    and i wrote import also.
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
    my errors are
    Error(64,78): incompatible types; found: oracle.apps.fnd.framework.webui.beans.OAWebBean, required: oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean
    Error(65,13): duplicate definition of variable projnumber in method processFormRequest(oracle.apps.fnd.framework.webui.OAPageContext, oracle.apps.fnd.framework.webui.beans.OAWebBean)
    Error(66,9): variable bean not found in class wnsgs.oracle.apps.pa.projectinfo.webui.ProjectInfoCreateCO
    plz help me.
    its very urgent
    Thanks
    Edited by: Latha on Jan 4, 2012 9:57 PM
    Edited by: Latha on Jan 4, 2012 10:00 PM

  • Inserting multiple records in to database table using webdynpro abap

    Hi all,
    I have created a username inputfield,a button and a table
    with one coloumn.
    If i enter  names in the input field then the values should be
    displayed in that table.
    Even i have got the answer i am not able to insert
    the values in to database(ztable) table.
    i.e. only one value(1st) was inserted the second value was
    not inserted ....
    so kindly send me the coding to insert multiple records
    into the database table......
    by,
    ranjith

    hi Ranjith,
    If you want to insert multiple records from the webdynpro view table to database table then try the following code.
    DATA lo_nd_tablenode TYPE REF TO if_wd_context_node.
      DATA lo_el_tablenode TYPE REF TO if_wd_context_element.
      DATA ls_tablenode TYPE wd_this->element_tablenode.
      DATA it_tablenode LIKE STANDARD TABLE OF ls_tablenode.
      navigate from <CONTEXT> to <tablenode> via lead selection
      lo_nd_tablenode = wd_context->get_child_node( name = wd_this->wdctx_tablenode ).
      get element via lead selection
      lo_el_tablenode = lo_nd_tablenode->get_element(  ).
      get all declared attributes
      lo_nd_tablenode->get_static_attributes_table(
      IMPORTING
        table = it_tablenode ).
    MODIFY databasetablename FROM TABLE  it_tablenode.
    here it_tablenode is the internal table which holds the value from webdynpro view..
    Regards,
    Shamila.

  • When and How to close database connection in JSP?

    Hi there,
    I am using MySQL and JDBC 3.0, in my system, When and How to close database connection in JSP?
    Thanks in advance.
    Lonely Wolf
    <%@ page session="true" language="java" %>
    <jsp:include page="checkauthorization.jsp" />
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%--
    Execute query, with wildcard characters added to the
    parameter values used in the search criteria
    --%>
    <sql:query var="availablecomputerList" dataSource="jdbc/Bookingcomputer" scope="request">
    SELECT * FROM computer where status=0
    order by s_code
    </sql:query>
    <html>
    <head>
    <title>Search Result</title>
    </head>
    <body bgcolor="white">
    <center>
    <form action="checkin.jsp" method="post">
    <input type="submit" value="Back to Check-in Page">
    </form>
    <c:choose>
    <c:when test="${availablecomputerList.rowCount == 0}">
    Sorry, no available computer found.
    </c:when>
    <c:otherwise>
    The following available computers were found:
    <table border="1">
    <th>Computer</th>
    <th>Description</th>
    <th>Status</th>
    <c:forEach items="${availablecomputerList.rows}" var="row">
    <tr>
    <td><c:out value="${row.s_code}" /></td>
    <td><c:out value="${row.description}" /></td>
    <td><c:out value="${row.status}" /></td>
    </tr>
    </c:forEach>
    </table>
    </c:otherwise>
    </c:choose>
    </center>
    </body>
    </html>

    when should you close the connection? when you're done with it.
    how should you close the connection? like this: conn.close();
    that said, doing this in a JSP page is bad form and not recommended
    JSP's typically don't contain ANY business or data logic

  • JSF and Database tables in the pages...

    Hi guys,
    I am following this excellent tutorial http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html as I am learning JSF using JDeveloper. Unfortunately since my knowledge of JDeveloper and JSF being rather limited, there is one section in the tutorial that I am unable to understand. If you do a search on that web page and type in 'column1' without the quotes, I am unable to understand where the author got that object from.
    Barring that I also had another question. I just saw a demo video of Netbeans taking the Entity beans generated from the database tables and creating JSF pages based on the tables with one click that showed the data very nicely in a table format in the jsp page. Is there some sort of functionality like that? Or is that JEE 5 specific? Also is JDeveloper JEE 5 compliant as of yet?
    Sorry for the laundry list of questions.
    Surya

    Before I make an even bigger fool of myself in this forum, the tutorial has 2 parts. Does part 2 depend on part 1 to get it working right because I feel as if I am missing something.
    Also it seems that for however many columns we are able to retrieve from our ResultSet we should know beforehand so we can code up the DataTable. This might not be the case all the time I guess, so is that where the JSF support in the ADF framework comes in and makes life a lot easier for the developer?
    Thanks for answering all my questions.
    Surya

  • Not updating database table after editing using theADFapplicationJdev10.1.3

    Hi
    I created the Sample Browse and Edit JSF JSP page oracle ADF application as explained in the cuecards in Jdev10.1.3.
    After editing the department table rows in browser i am checking the database tables for the changes.
    But my table are still with the old data.they are not updating with the values i changed in the browser.
    i followed the steps correctly as explained in cuecards.
    where i am going wrong.
    What i have to do to commit the changes in to database in my ADFApplication.Did i need anything to add my code.

    In Jdev 10.1.3,there is no operations folder directly under the Application data module control.
    there is only constructors,merge entity,persist entity,refresh entity,remove entity and findalldepartments(),findallemployeeas() nodes under the application data module control.
    In findalldepartments,findallemplloyees the operations node is there.under that i don't have the commit .i have only create,execute,first,previous,last,next,delete,removerowwithkey,setcurrentRowWithkey,setcurrentRowWithkeyValue under the operation node.
    so how can i commit the operations in database.
    Please help me.

  • Sql database connection in jsp

    Hi,
    I am new to java.
    I know how to connect the database in the java using the javacodings [jdbc] but i am don't know how to connect the database using the jsp.
    Is it easy. If so, can any one help me in this regards.
    Any sample codes or white paper available.
    thanks in advance,
    Regards,
    sa

    Hi,
    Here's a simple application i write to test JSTL.
    Using JSTL is easier.
    Create a directory named tests in your webapps tomcat directoty.
    In this, create a web-inf dir and inside a lib dir.
    Copy JSTL.JAR ans STANDARD.JAR in tests/web-inf/lib/ which are lib for JSTL (found on apache foundation web site, jakarta implementation).
    Copy you jdbc driver in jakarta-tomcat/common/lib dir.
    Here is a file to input some data from an HTML form:
    Create saisie.jsp and record.jsp in you tests apps dir.
    saisie.jsp:
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
    <title>Simple Example</title>
    </head>
    <body>
        <h1> Saisie de donn�es  </h1>
        <form name="saisie" action="record.jsp" method="get">
            Code :<input type="text" name="code"/>
            Text :<input type="text" name="text"/>
            <input type="submit" name="submit"/>
        </form>
    </body>
    </html>and record.jsp:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <%@ page isELIgnored ="false" %>
    <html>
    <head>
    <title>Simple Example</title>
    </head>
    <body>
    <sql:query var="result"  maxRows="100">
         select * from ess
    </sql:query>
    <table>
         <!-- Affichage de l'ent�te avec le nom des colonnes -->
         <tr>
         <c:forEach var="name" items="${result.columnNames}">
              <th>${name}</th>
         </c:forEach>
         </tr>
         <!-- Affichage des donn�es avec 'rowsByIndex' -->
         <c:forEach var="ligne" items="${result.rowsByIndex}">
         <tr>
              <c:forEach var="valeur" items="${ligne}">
                   <td>${valeur}</td>
              </c:forEach>
         </tr>
         </c:forEach>
    </table>
    <c:set var="code_id" value="${param.code}"/>
    <sql:update>
        INSERT INTO ESS (ID,TEXT) VALUES (?,?)
        <sql:param>${param.code} </sql:param>
        <sql:param>${param.text}</sql:param>
    </sql:update>
    </body>
    </html>Here's web.xml file to create in tests/web-inf dir:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <description>Learning JSTL (or whatever you like</description>
        <context-param>
              <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
              <param-value>jdbc:postgresql://127.0.0.1/gihe,org.postgresql.Driver,gihe,****<param-value>
         </context-param> 
    </web-app>web.xml contains the datasource definition, the jdbc driver, the url, user and password.
    saisie.jsp is a standard html file.
    record.jsp use web.xml datasource to connect to the database and use JSTL tag to insert some data.
    more explanations on java sun site.

  • Creating and updating table in JSP Through ADD and SAVE button

    how do I create a table in JSP which has certain number of columns and rows. I have a button called "ADD", which when clicked should add the data I entered. How do I update and save the same?, if there are buttons called "SAVE" and "DELETE".

    Do u want to add it to the database or just in the JSP Cache???
    I think if you want to add to DB, take the subject offline.
    My Mail id is [email protected]

  • Authentication & Authorization with SSO, JAAS and Database Tables mix

    Hi,
    I'm looking for how manage Authentication & Authorization in a J2EE ADF+Struts+JSP application.
    I'm interested in use SSO for authentication (I just did it programatically & dynamically already), and now I would like to could define authorization using database tables with users, groups, profiles, individual permissions, ..., (maitanined dynamically by web application admin) throught JAZN (JAAS or however is said) but not statically defining roles, groups, users, ... in jazn xml files.
    I saw that exists the possibility to create a custom DataSourceUserManager class to manage all this, and this gave me the idea that this could be possible to do (I was thinking in make a custom Authorization API over my application tables, without JAZN) but what is better that use and extended and consolidated aprox like JAZN.
    Anybody could tell me if my idea could be possible, and realizable, and maybe give me some orientation to build this approach.
    A lot of thanks in advanced.
    And sorry, excuse my so bad english.
    See you.

    Marcel,
    Originally the idea was to create a post to only explain how to do authentication using a Servlet filter. However,
    I have recently added code to the JHeadstart runtime and generators to enable both JAAS and 'Custom' authentication AND authorization in generated applications. Therefore, this post will be made after we have released the next patch release, as it will depend on these code changes.
    We currently plan to have the patch release available sometime in the second half of May.
    Kind regards,
    Peter Ebell
    JHeadstart Team

  • NULL COLUMN ON DATABASE TABLE

    HELLO AGAIN TO EVERYONE AND TO EVERY ONE WHO IS BEEN REPLYING MY MESSAGES,
    I AM STIL HAVING PROBLE WITH MY JSP AND FORM(HTML).
    THE PROBLEM IS , THE NAMECOLUMN OF MY DATABASE REMAINS NULL WHEN I QUERY IT AFTER ENTERING DATA THROUGH THE FORM.COLUMN TYPE IS A VARCHAR . THE DATA ENTERED IS BEEN ENTEREDTHROUG THE request.getParameter() method OF THE JSP I DONT SEEM TO FIND ANY ERROR WITH MY CODE.
    THE CODE ARE PROVIDED BELOW.CAN ANYONE TELL ME WHAT IS HAPPENING BEHIND THE SCENE ON THE NAME COLUMN .I AM NEW TO JSP.
    jsp code
    try{
    Class.forName("com.mysql.jdbc.Driver");
    conn= DriverManager.getConnection("jdbc:mysql://localhost/school","barth","barth");
    // stat = conn.createStatement();
    // String name1 = request.getParameter( "name ");
    //int idnum = Integer.parseInt( request.getParameter("id") );
    //int age2 = Integer.parseInt( request.getParameter("age") );
    PreparedStatement stat = conn.prepareStatement(" INSERT INTO student " +
    " VALUES( ?, ? ,?)");
    stat.setInt(1,Integer.parseInt( request.getParameter("id") ));
    stat.setString(2, request.getParameter( "name "));
    stat.setInt(3,Integer.parseInt( request.getParameter("age") ));
    stat.executeUpdate();
    conn.close();
    catch(Exception e)
    {e.printStackTrace();}
    sample of database table column.
    *******************************************************************************mysql> select * from student;
    | id | name | age |
    | 10 | NULL | 76 |
    | 10 | NULL | 76 |
    | 9 | NULL | 34 |
    | 11 | NULL | 45 |
    | 12 | NULL | 23 |
    14 rows in set (0.13 sec)
    mysql>

    First of all, don't use all CAPS when typing, it gets difficult to follow your text! Also try putting your code in [ code ] -tags in the future, it's so much easier to follow code that way.
    Looking at your database it appears as if name isn't holding a value when you use it in your database call.
    Verify that it *IS holding a value, you can do that by printing it to the console, i.e.
    System.out.println( request.getParameter("name")  );

Maybe you are looking for

  • Function to make line itens settlement in a Project

    Hi, We are having an issue in a development for the automatic line item settlement in a program since we can´t use CALL TRANSACTION because the standard way (CJIC - program RKPEP012) is an ALV report. Does anyone know another way of creating a settlm

  • New tab implementation at item level in ME21N/ME22N/ME23N.

    Hi Friends, I have implemented two badis 1. ME_GUI_PO_CUST and 2. ME_PROCESS_PO_CUST to get a new tab at item level in ME21N/ME22N/ME23N, I could see this new tab only in ME23N but not in ME21N/ME22N, and I found that Badi ME_PROCESS_PO_CUST is not g

  • How to deploy SSRS 2008 reports to Sharepoint 2013.

     Hi,    Can some one guide me how to deploy SSRS 2008 reports to SharePoint 2013 by giving the exact steps from where to begin. We have all our reports deployed in SharePoint 2010.Need to migrate those reports to Sharepoint 2013 instance. I also want

  • Doubts in bi

    Hi friends, what is invantory data sources in bi any one send me documentation wat is the cumulative key figures and open close balance in bi. Regards.

  • PSE11 Face Recognition Window Disapears

    I recently upgraded from PSE8 to PSE11.  I am trying to use face regonition to tag the people in my photos.  There are only a few photos with people tagged in them that I did manually.  Most photos are newly imported from camera, but some where conve