Solved

Dynamic table

Posted on 2003-10-27
16
589 Views
Last Modified: 2008-02-26
I have a jsp form called view.jsp.

When the user clicks the add button, a pop window would pop up and asks the user to enter the details such as

  Name of Color,
  Type of Color,
   Description,
When the user has entered the details, he presses the ok button on the pop up window, the data gets inserted into the database
(The user could add as many as color and details and table grows)

My problem is that i need to display the details of the color in a dynamic table( i don't know how) with a checkbox and the details
For example
Checkbox | Name of Color|Type of Color|Description

How do i add this to the dynamic table and i need not explicits refresh the view the jsp( i don't know how)

The name of table is Col
Fields
Colorid | typeColor| Desc|

Thanks
0
Comment
Question by:Jasbir21
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 5
16 Comments
 
LVL 2

Expert Comment

by:Karaa
ID: 9626655
the details  of color are coming from db or some where else?
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9626685
<%
String cname;/// coming from db
String   check="checked"; or check="";/// this check variable may have two values coming from database either "checked" or ""
%>
use some For loop

<td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.print(check);%>><br></td>
<input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" >
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9626720
if u want to do SQL search of table from db u can use
String      str = "SELECT color,type,desc,checked FROM Col";
            rset = stmt.executeQuery(str);%>
<%
            while (rset.next())
                  {
                  String cname= rset.getString(1);
                  String type= rset.getString(2);
String desc= rset.getString(3);
String checked= rset.getString(4);

                  %>
                  <td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.println(checked);%>><br></td>
<td ><input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" > </td>      
<td ><input name="type" type="text" id="type" value="<%=type%>" size="19" align="top" width="110" > </td>      
<td ><input name="desc" type="text" id="desc" value="<%=desc%>" size="19" align="top" width="110" > </td>                  <%      }      %>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Jasbir21
ID: 9627352
Hi,
 
  I tried that but i got this error:server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
      org.apache.jsp.jsp2.orga_jsp._jspService(orga_jsp.java:259)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9627366
if you don't want to refresh the view.jsp, then there is an example of how to do it with javascript:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20676182.html
it was about another question but have the right example in it.
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9630309
The reason may be you have not initialised JSP variables
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9630313
it is better you post your code
0
 

Author Comment

by:Jasbir21
ID: 9687185
....java bean classes and connection with database
My problem is that when the user clicks the new button , the project.jsp should be displayed and when the info is entered the page needs to be refreshed or what ever (dynamic table needs to be displayed)
Could anyone plssssssssss help me , i really  needs this urgently

This is the part of the code:

<table border="2" BGCOLOR="#FFFFF0" width="80%" CELLPADDING="4">
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
Project Name
</td>
<td>
Description
</td>
<td>
Duration
</td>
<td>
Skills Required
</td>
</tr>
</table>

</p>
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">
</p>
<input type="submit" value="Submit">
</form>
</font>
</body>
</html>
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9687616
>> Could anyone plssssssssss help me , i really  needs this urgently
we need more information to help you, you might want to help you self by response to us quickly.

can you please post what you have for your view.jsp? or let us know if you don't even know where to start.
0
 

Author Comment

by:Jasbir21
ID: 9698033
so sorry for the late response.

 I don't know where to start, except that my connections the database and everything works fine, and for the dynamic table part i just have that html code,
The rest of the form is just enterin g data...


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9698530
assuming you know how to get a resultset from database:

<% while( resultSet.next() ) { %>
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
<%=resultSet.getString( "ProductName" )%>
</td>
<td>
<%=resultSet.getString( "Description" )%>
</td>
<td>
<%=resultSet.getString( "Duration" )%>
</td>
<td>
<%=resultSet.getString( "SkillsRequired" )%>
</td>
</tr>
<% } %>
0
 

Author Comment

by:Jasbir21
ID: 9698806
Hi,
  Sorry for not being clear from the beginning :
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">

 My problem when the user clicks the new button, a window should pop up, called project.jsp.
Where the user is able to enter data into table project.When the user clicks submit button on project.jsp the dynamic table in view.jsp needs to be displayed.
There is also other information entered by the user on view.jsp.
I mean, how can it be done if the user
clicks new, the project.jsp pops-up ,user enters info press submit, it gets displayed on view.jsp(dynamic table) with other info of user..


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9702479
so your question is rather on how to handle the popup windows instead how to display a dynamic table with data from database.

read this thread from beginning to the end and you should know what you need to do.

Let me know if you have futher enquires.
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 150 total points
ID: 9709782
0
 

Author Comment

by:Jasbir21
ID: 9751764
thank you ans sorry for the late reply....
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9752902
glad to know your problem is resolved and thanks for the A grade.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with LDAp login using jsp 6 118
difference between member and local variables. 29 143
'exit' is not valid keyword in java 14 163
Java Script nested call 3 88
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question