Link to home
Start Free TrialLog in
Avatar of Jasbir21
Jasbir21

asked on

Dynamic table

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
Avatar of Karaa
Karaa

the details  of color are coming from db or some where else?
<%
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" >
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>                  <%      }      %>
Avatar of Jasbir21

ASKER

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
if you don't want to refresh the view.jsp, then there is an example of how to do it with javascript:
https://www.experts-exchange.com/questions/20676182/Dynamic-Table-Cell-Properties.html
it was about another question but have the right example in it.
The reason may be you have not initialised JSP variables
it is better you post your code
....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>
>> 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.
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
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>
<% } %>
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
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.
ASKER CERTIFIED SOLUTION
Avatar of kennethxu
kennethxu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you ans sorry for the late reply....
glad to know your problem is resolved and thanks for the A grade.