How to add tables in JSP page dynamically?
Hi all,
I am Girish, i am new to Java. I want to create a html page.
The main requirment in the page is ...
Initialy the page will contains a table which will accepts some data.
If the user want to enter some more information he can click one add button such that a new table will be created. If he wants to delete created table he can select delete button such that the table will be deleted in the same JSP page.
Please give me a solution.. how to achieve this requirment.
Waiting for reply..
Thanks in advance...
Regards,
Girish.K
this is a sample.. you can give it a try:
whatever jsp
<%@ page contentType="text/html;charset=windows-1252"%>
<%@page import="java.util.*,mypackage.TestBean"%>
<%
String name = request.getParameter("name")!=null?request.getParameter("name"):"";
String age = request.getParameter("age")!=null?request.getParameter("age"):"";
System.out.println(name);
System.out.println(age);
Collection col = new ArrayList();
col = (Collection)session.getAttribute("col")!=null?(Collection)session.getAttribute("col"):new ArrayList();
TestBean tBean = new TestBean();
if(!name.equals(""))
tBean.setName(name);
if(!age.equals(""))
tBean.setAge(age);
if(!age.equals("") || !name.equals(""))
col.add(tBean);
session.setAttribute("col",col);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<title>untitled</title>
</head>
<body>
<form>
<table cellspacing="0" cellpadding="0" border="1" width="200">
<tr>
<td>Name</td>
<td>
<input type="text" name="name"/>
</td>
</tr>
<tr>
<td>Age</td>
<td>
<input type="text" name="age"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
<%
if(col.size()>0){
Iterator iter = col.iterator();
%>
<table cellspacing="0" cellpadding="0" border="1" width="200">
<tr>
<td>
NAME
</td>
<td>
AGE
</td>
</tr>
<%while(iter.hasNext()){
tBean = (TestBean)iter.next();
%>
<tr>
<td>
<%=tBean.getName()%>
</td>
<td>
<%=tBean.getAge()%>
</td>
</tr>
<%}%>
</table>
<%}%>
</form>
</body>
</html>TestBean.java
package mypackage;
public class TestBean
private String name;
private String age;
public TestBean()
public String getName()
return name;
public void setName(String name)
this.name = name;
public String getAge()
return age;
public void setAge(String age)
this.age = age;
}
Similar Messages
-
How to display table in jsp pages
hi all ,
i want to diaplay the table in jsp page...ie,if i click on some option then i need to get the table in jsp page
wiil u plz help me
thanks in advance
chintuhi all..
i didnt ask how to design table in jsp...i am asking how to diaplay the table with data already stored in database...i just want to retrive the values in table and display in jsp.....
thanks in advance...
chintu -
How to add table in SAP Non interactive forms in webdynpro java
Hi Experts,
I have a requirement in webdynpro java.I have a print button.On clicking print button a pdf will be opened.
This pdf will have data from the webdynpro view.I want to know how to add table in the adobe pdf.The webdynpro view will have many rows of table(rows will keep changing as per the size of the data output).How to send this data to adobe.How do we bind the node to the table in the adobe.How to automatically
Please suggest.
Thanks,
Rajani
Edited by: Rajani Nandagiri on Dec 26, 2008 8:58 AMRajani,
Take a look at below links, it will help you.
[Handling Dynamic Length Tables in Adobe Forms|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0859ad1-53aa-2a10-78ae-99e41c407669]
[Integrate tables & Images in Adobe Web Dynpro|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/dynamic%20non-interactive%20pdf%20form.pdf]
[How to Handle Table Input and Output|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/7.0/adobe/how%20to%20handle%20table%20input%20and%20output.pdf]
[How Tou2026deal with Table input and display in Interactive Forms|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00c4041d-188d-2910-6ea2-b4d5155f56e0]
Chintan -
How to print report in jsp page?
excuse me,i am new to jsp
may i know how to pritn report in jsp page or html?
tqhere is a hacked up example.. i ripped out a lot, so it may not compile, but you get the idea... the full version is really long and not much new info.. just all awt/display stuff...
package rowe;
import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.sql.*;
import utility.*;
import java.awt.print.*;
public class rowePrint extends JFrame implements ActionListener, Printable{
String printType = "";
static JButton j = new JButton("Print");
FontMetrics fm;
String jID, promotion, product, jComments;
public void getInfo(int jid) {
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:rowe");
Statement stmt = conn.createStatement();
rs = stmt.executeQuery("select j.id as jID, j.comments, p.title as pTitle, p.product, p.packagingCartonCost, p.foldingQuarterCostPerM, p.foldingQuarterCostPerM, j.customizationOption as setupFee, p.perMcost, p.qtyCarton, d.name as dName, d.contact as dContact, d.email as dEmail, d.address as dAddress, d.city as dCity, d.state as dState, d.zip as dZip, d.phone as dPhone, d.fax as dFax, r.name as rName, j.totalQty, j.orderIn, j.estFreight, j.miscCost, j.coverSelection, j.imprintSelection from jobs j, promotions p, dealers d, reps r where j.promotion = p.id and j.dealer = d.id and j.rep = r.id and j.id = " + jid);
rs.next();
jID = rs.getString("jID");
jComments = rs.getString("comments");
promotion = rs.getString("pTitle");
product = rs.getString("product");
} catch (Exception e) {
System.out.println("getinfo: " + e);
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton) {
wookie();
public void wookie() {
PrinterJob printJob = PrinterJob.getPrinterJob();
Paper paper = new Paper();
PageFormat page = new PageFormat();
paper.setImageableArea(0, 0, 600, 780);
page.setPaper(paper);
printJob.setPrintable(this, page);
try{
//printJob.pageDialog(page);
// if (printJob.printDialog()) {
printJob.print();
} catch (Exception e) {
System.out.println("wookie1" + e);
public static void main(String[] args) {
rowePrint at = new rowePrint("Invoice");
at.getInfo((new Integer(args[0])).intValue());
at.drawShapes();
// at.wookie();
public void drawShapes() {
setBounds(0, 0, 670, 550);
addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {System.exit(0);}});
j.setBounds(10, 10, 10, 10);
j.addActionListener(this);
getContentPane().setLayout(null);
getContentPane().add(l);
getContentPane().add(j);
show();
public rowePrint(String s){
printType = s;
public void paint(Graphics g) {
g.setFont(new Font("Serif", Font.BOLD, 18));
g.drawString(promotion, 20, 30);
g.setFont(new Font("SansSerif", Font.PLAIN, 4));
g.drawString("" + new java.util.Date(), 20, 37);
g.setFont(new Font("Serif", Font.BOLD, 21));
g.drawString("Rowe Furniture", 440, 35);
g.fillRect(440, 40, 145, 25);
g.setColor(Color.white);
fm = g.getFontMetrics(new Font("Serif", Font.BOLD, 21));
g.drawString(printType, 512 - (fm.stringWidth(printType) / 2), 60);
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
paint(g);
return Printable.PAGE_EXISTS;
} -
How to create graphs on JSP page in JDeveloper 10.1.3
Hi all,
Is there an easy way to create graph objects with JDeveloper 10.1.3? I have taken a look to some tutorials, but it looks like they all use the "drag/drop graph from the data control palette" method.
E.g. I got example 88 to work from http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html, but I have no idea how to get the BIGraphDef1.xml object and how to link it to a set of data.
Are there some tutorials to show how graphs can be used in JDev 10.1.3?Frank,
This is what I did to implement the graphic manual, but I think, I forgot something...
1. create a new application with projects DataModel and UserInterface
2. in the DataModel I created a similar master/detail view as the one of Steve, this is named:
TestModuleDataControl
\--DepView
__\--Deptno
__\--Dname
__\--Loc
__\--EmpView1
____\--Sal
3. I created a new jspx page and added a graph tag:
<f:verbatim>
<graph:Graph data="${bindings.DepartmentsEmployeesInDepartmentGraph}"
imageHeight="200" imageWidth="400"/>
</f:verbatim>
4. in the page definitions I added
<graph id="DepartmentsEmployeesInDepartmentGraph"
IterBinding="EmployeesInDepartmentIterator"
ControlClass="oracle.dss.graph.Graph"
SeriesLabel="Ename"
GraphPropertiesFileName="userinterface.BIGrap1hDef1"
SeriesType="SINGLE_SERIES">
<AttrNames>
<Item Value="Sal"/>
</AttrNames>
</graph>
5. I added also the iterator:
<iterator id="EmployeesInDepartmentIterator" Binds="EmpView1" RangeSize="10"
DataControl="TestModuleDataControl"/>
6. I copy/pasted the BIGraphDef1.xml from Steve's project into 'Application Sources'\userinterface.
7. in the web.xml file in WEB-INF I added:
<servlet>
<servlet-name>GraphGeneratorServlet</servlet-name>
<servlet-class>oracle.jbo.html.jsp.graph.GraphGeneratorServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GraphGeneratorServlet</servlet-name>
<url-pattern>/GraphGeneratorServlet</url-pattern>
</servlet-mapping>
8. when I run the page, I can't see the graph and there are also no errors. I think I mis a global setting somewhere...
Is there anything I forgot to do?
note: if I add a new jsp page into steve's application, I do can see the graph if I perform the steps mentioned above...
I just found out that, If I create the graph on a page which is in the root directory, then it works. If I put it in a subdirectory, it doesn't:
- create graph as mentioned above on a page: web content/myGraph.jspx --> works
- create graph as mentioned above on a page: web content/app/myGraph.jspx --> doesn't work...
Does somebody know where to put a setting/parameter to get the Graph visible in the subdirectory app? -
How to add totals for each page in main window
hi
i have problem in scripts
how to add total in first page ending and carry it to second page , at the end of second page again adding total and so on until last page.
very urgent
regards
ratnaHi,
Check these
http://help.sap.com/saphelp_40b/helpdata/en/d1/8035c3454211d189710000e8322d00/content.htm
http://membres.lycos.fr/jolyeric/SAP/Note_de_Cours_Ben/Sapscript/SAPscript_Control_Commands.doc
try to use the command 'summing' along with one text symbol .Keep the if condtion when page changes at that time u dispay the total as ur keeping the total in text symbol it can be dispayed in the next page
or this is round about way
loop at <table>.
call write_form.
endloop.
here u declare a variable 'c' and increment it by 1 in each loop. Then u chgeck if the program has started printing second page then u can print the number of records before printing the next page.
eg :
data : c type c value '0'.
loop at <table>.
c = c + 1.
call write_form.
endloop.
in form:
check when the next page is being printed, then u can print the number
of lines 'c'.
Feel free to revert back.
--Ragu -
How to add a watermark in Pages 5.0
Hello!
Could anyone please explain to me how to add a watermark in Pages 5.0
Thank youHi have found the solution. You need go into the View menu and make sure that you have checked the Show Invisibles option. Once you can see the invisibles, you should see a blue line at the top of the "blank" page with a small "document" icon at the right of the line. You need to delete this blue line/icon which will delete the whole page as long as there are no other "invisible items" which may also need to be deleted.
I did the above and my blank page disappeared from the thumbnails view immediately. -
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.
AnuragHi,
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. -
How to do transactions in jsp pages using Java & MySQL ?
Hi,
I'm a newbie..
I'd like to know "How to do transactions in jsp pages using Java & MySQL ?"
Platform: Windows XP, Apache Tomcat 5.5, MySQL 5, Java bean without EJB
what are the the different types of transactions? Differences between them?Pls provide examples?
Which among them is the best method to implement a transaction?
Pls help me...
thnx in advance...http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
-
Does any know how to add web clips to Pages on iPad?
Does anyone know how to add web clips to Pages in iPad? Thanks in advance.
i have no idea how they were lost - i think i must have updated the ipad and then i found the documents to be lost ? i restored the last back up which should have had the documents but to no avail??
-
How to call Servlet from jsp page and how to run this app using tomcat..?
Hi ,
I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
Please tell me how to do this into jsp page..?
Also i wanted to execute this application using tomcat.
Please tell me how to do this...? what setting are required for this...? what will be url ..??
Thanks.well....my problem is as follows:
whenever i type...... http://localhost:8080/appName/
i am getting 404 error.....it is not calling to login.jsp (default jsp)
but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
plz help me. -
How to develop and Run .jsp page from Jdeveloper 10g
Dear All,
I need to develop one small JSP page using Jdeveloper10g. pls share information How to develop and Run .jsp page from Jdeveloper 10g.
Thanks in Advance,
Hanimi.Hi Gyan,
Any Idea how to get DB connection for JSP Pages.
Our Java guys developed one JSP page for Login page.
After Log in instead of standard responsibilites page we calling custom jsp page, For getting DB connection they defined one properties file and hard coded DB details on that file and calling, but client is not accepting hard coding.
Pls give any idea for getting DB connection directly in JSP pages.
Hanimi. -
Does anywone now how to add cambria police to pages?
does anywone now how to add cambria police to pages?
Cambria is a 'serif font that came with Windows Vista and Microsoft Office 2007, specifically designed for screen reading and to keep the good integrity of small characters when printing.' ('Police de caractères' is French for 'font'.)
Quit Pages. Double-click the font to examine it and have the option to add it to Font Book. If it's compatible with Macs it will be added to the font list and be available in Pages. -
HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH
Hi,
HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH?
Thanksemekaco wrote:
Hi,
HOW DO I STOP MY JSP PAGE FROM INSERTING DATA IN DATABASE EACH TIME REFRESH?
ThanksSTOP SHOUTING!
now, while displaying the form generate some random number, or take the current time in millis or whatever. Put that number in a hidden field. Insert that unique number along with the real data into the database, but before you do check if the number already exists. If it does you can be pretty sure this is a resubmit of the same data, so don't allow it. This is one way of many to prevent resubmission of existing data.
A good way to prevent a refresh from resubmitting altogether is to do a redirect to a result page right after you deal with the POST request. When the user presses refresh then, he/she will refresh the redirect and not the form submit. -
How to add fragment in jsf page using include tag in jdeveloper
Hi all
Can you tell me wat is syntax of using include tag .or how to add fragment in jsf page ..
Edited by: 947228 on Jul 18, 2012 5:01 AMHi,
Why do you want to do that?
Check [url https://blogs.oracle.com/jheadstart/entry/avoid_use_of_jspinclude_where]this out before proceeding further.
Btw, always mention your JDev version, clear usecase to get help.
-Arun
Maybe you are looking for
-
HT201250 Backing up an auxiliary drive with Time Machine
I have iphoto loaded on an external lacie drive to free up space on my macbook pro. I use a mybook and time machine to backup my macbook pro, but it won't let me include the Lacie in the backup even though there is plenty of room. I want to make su
-
Photos do not appear in iPhoto after upgrade
Hi, I have searched around and no one else seems to have encountered this problem. I upgraded my apple to a iMac with Leopard and iPhoto 08, from an old Tiger machine. I moved the iPhoto library into Pictures and then loaded iPhoto. I agreed to allow
-
Regarding the first level navigation par file customization
Hi i require the help on the first level navigation par file customization. i downloaded the rthe required par file from the server for changes. the name of the par file is <b>com.sap.portal.navigation.toplevelsingle.</b>. my requirement on this par
-
Wireless connections need help on what type to get.....
I have an iMac G5 and need to make it wireless. Due to construction. I believe its a 17 inch 1.8gh( I think). What would I need to make it wireless? Also my iMac is going to be a good 100-150 feet away and up a story from the dsl box. Plus the Floor
-
Hi, I have the latest DNG converter downloaded and running but it still doesnt support my Olympus E600. The E600 is a stripped down version of the Olympus E620 which is listed. How long before an update will be available or is there another way aroun