Results 1 to 2 of 2
  1. #1
    aalhazm is offline Member
    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Default Add and Display in the same page

    I have to do add form and display the data in the same table.
    How to do that?

  2. #2
    Join Date
    Jun 2013
    Posts
    9
    Rep Power
    0

    Default Re: Add and Display in the same page

    Your request is a bit short.

    Do you want to create a form containing a table in html and fill the data with java?
    Than you could do something like this in a JSP:

    <form>
    <table>
    <tr><td>col1Name</td><td>col2Name</td><td>col3Name</td></tr>
    <%
    Object obj = request.getParamter("paramName");
    if(null != obj) {
    MyObj[] arr = (MyObj[])obj;
    for(MyObj value: arr) {
    %>
    <tr><td><%=value.valOne%></td><td><%=value.valTwo%></td><td><%=value.valThree%></td></tr>
    <%
    }
    }
    %>
    </table>
    </form>


    In this example the row "<tr><td><%=value.valOne%></td><td><%=value.valTwo%></td><td><%=value.valThree%></td></tr>" will be added to html for each Object value in the Array arr.
    The value.valOne would be the access to one attribute in the object, instead you can also use a method like getValOne().
    If you have a list or collection instead a array it would work nearly the same.

    The request.getParameter() will only work if you use a servlet or controller.

    If you do not have the data on start of the page, you have simple to load them via ajax and than fill the table with JavaScript.

Similar Threads

  1. display image from database on jsp page
    By rdangelo in forum JavaServer Pages (JSP) and JSTL
    Replies: 9
    Last Post: 09-20-2012, 07:54 PM
  2. Display data from list on same jsp page
    By reubenmk in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-13-2012, 12:12 PM
  3. JSP page display
    By cnu.nandhikonda@gmail.com in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 02-01-2012, 11:48 AM
  4. Display image on jsp page
    By shuchi.vishnoi in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 11-30-2010, 01:46 PM
  5. how to display image in jsp page(Struts)
    By rama6262 in forum Advanced Java
    Replies: 1
    Last Post: 12-21-2007, 08:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •