Listing Editing Jsp forms/Tables

Pls I am trying to develope an application with a table just so that as I am inserting it will be listing , and I can also do updates
here is my bean
public class Tay
     private String MtId;
private String chargeCode;
     private String description;
     private String status;
     public Tay(String MtId,String chargeCode,String description, String status)
     this.MtId = MtId;
          this.chargeCode = chargeCode;
          this.description = description;
          this.status = status;
public void setMtId(String MtId)
     this.MtId = MtId;
public String getMtId()
     return MtId;
public void setChargeCode(String chargeCode)
     this.chargeCode = chargeCode;
public String getChargeCode()
     return chargeCode;
public void setDescription(String description)
     this.description = description;
public String getDescription()
     return description;
public void setStatus(String status)
     this.status = status;
public String getStatus()
     return status;
Model
import java.util.*;
import java.sql.*;
//import Listing.*;
public class Display
     Connection cn;
     Statement st;
     ResultSet set;
     PreparedStatement ps;
     public Display()
     *     method used to connectDb
     public void connectDb()
          try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               cn = DriverManager.getConnection("jdbc:odbc:taysay","sa","magbel");
               st = cn.createStatement();
          catch(Exception ex)
               ex.printStackTrace();
     method used to get the data from database.
     public ArrayList DisplayByQuery()
          ArrayList list = new ArrayList();     
          try
               connectDb();
               String Query = "select * from tblTony";
               set = st.executeQuery(Query);
               while(set.next())
                    Tay a =new Tay(""+set.getInt("MtId"), set.getString("chargeCode"),set.getString("description"),set.getString("status"));
                    list.add(a);
          catch(Exception err)
               System.out.println(err.toString());
          return list;
     public String updateMtId(String MtId, String chargeCode, String description, String status)
          String UPDATE_QUERY = "UPDATE tblTony " +"SET MtId=?,chargeCode=?,description=?,status=?";
          PreparedStatement ps = null;
          String ret ="";
          try
               connectDb();
               ps = cn.prepareStatement(UPDATE_QUERY);
               ps.setString(1, MtId);
               ps.setString(2, chargeCode);
               ps.setString(3, description);
               ps.setString(4, status);
               int a =ps.executeUpdate();
                    if(a>0)
                         ret ="Records editted successfully.";
          catch(Exception ex)
               ex.printStackTrace();
          return ret;
     /*public ArrayList findAllMtId(){
          String filter = "";
          return findMtIdByQuery(filter);
     public Tay findTayByMtId(String MtId){
          String filter = " AND MtId = '"+MtId+"'";
          ArrayList records = findMtIdByQuery(filter);
          return (records.size() > 0)?(Tay)records.get(0):null;
public Tay findTayByChargeCode(String chargeCode){
     Tay tay = null;
     String filter = " AND chargeCode = '"+chargeCode+"'";
     ArrayList list = findMtIdByQuery(filter);
     if(list.size() > 0){
          tay = (Tay)list.get(0);
     return tay;
     public ArrayList getValueById(String filter){
          ArrayList records = new ArrayList();
          try{
               connectDb();
               set = st.executeQuery("select * from tblTony where MtId='"+filter+"'");
               while (set.next()) {
                    String MtId = ""+set.getInt("MtId");
                    String chargeCode = set.getString("chargeCode");
                    String description = set.getString("description");
                    String status = set.getString("status");
                    Tay tay= new Tay(MtId,chargeCode,description,status);
                    records.add(tay);
               System.out.println("the size of array is " + records.size());
          } catch (Exception e) {
               System.out.println("ERROR:Error Selecting Index MtId ->" + e.getMessage());
          return records;
My Jsp
(I do my inserts here)
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@page import= "java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MY DEMO APP</title>
<style type="text/css">
<!--
.style1 {
     font-family: Verdana, Arial, Helvetica, sans-serif;
     font-size: 12px;
     font-weight: bold;
.style2 {
     font-family: Verdana, Arial, Helvetica, sans-serif;
     font-size: 14px;
     font-weight: bold;
-->
</style>
<link href="images/stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {
     font-family: Verdana, Arial, sans-serif;
     font-size: 16px;
     font-weight: bold;
     color: #FFFFFF;
.style4 {color: #FFFFFF}
-->
</style>
</head>
<body>
<p> </p>
<p> </p>
<p>
<%
          String mMtId;
          String cCode;
          String dDesc;
          String sStatus;
%>
</p>
<form action="mag.jsp" method="post" name="form" id="form">
<p> </p>
<table width="91%" border="1" align="center" cellpadding="1" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#FFCC66"><div align="center"><span class="style3">DEMO PROJECT </span></div></td>
</tr>
<tr>
<td width="15%"><span class="style2">CHARGECODE </span></td>
<td width="31%"><input name="chargeCode" type="text" class="boxText" id="chargeCode" size="25" maxlength="25"></td>
<td width="12%" rowspan="2"><span class="style2">STATUS </span></td>
<td width="27%" rowspan="2"><span class="style1">Active</span>
<input name="sStatus" type="radio" value="A" checked>
<span class="style1">Closed</span>
<input name="sStatus" type="radio" value="C"></td>
<td width="15%"> </td>
</tr>
<tr>
<td><span class="style2">DESCRIPTION</span></td>
<td><input name="dDescription" type="text" class="boxText" id="description" size="70" maxlength="68"></td>
<td> </td>
</tr>
<tr>
<td colspan="5"><div align="right">
<input name="buttSave" type="submit" class="messageBox" id="buttSave" value="Save">
<input name="cmdExit" type="submit" id="cmdExit" value="Exit"onClick="exitPage()" />
</div></td>
</tr>
<tr>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">MtID</div></td>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">Charge Code </div></td>
<td colspan="2" bgcolor="#FFCC66"><div align="center" class="style1 style4">Description</div></td>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">Status</div></td>
</tr>
     <%
                    Display display = new Display();
                    ArrayList list = display.DisplayByQuery();
                    if(list.size() > 0 )
                         for(int x = 0; x<list.size(); x++)
                              Tay myshop = (Tay)list.get(x);
                              mMtId = myshop.getMtId();
                              cCode = myshop.getChargeCode();
                              dDesc = myshop.getDescription();
                              sStatus =myshop.getStatus();
%>
     <tr>
<td><%=mMtId%></td>
<td><%=cCode%></td>
<td colspan="2"><a href = "http://localhost:1234/tst/update.jsp?MtId=<%=mMtId%>"><%=dDesc%></a></td>
<td><%=sStatus%></td>
</tr>
     <%}
     %>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
my udpates jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@page import= "java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MY DEMO APP</title>
<style type="text/css">
<!--
.style1 {
     font-family: Verdana, Arial, Helvetica, sans-serif;
     font-size: 12px;
     font-weight: bold;
.style2 {
     font-family: Verdana, Arial, Helvetica, sans-serif;
     font-size: 14px;
     font-weight: bold;
-->
</style>
<link href="images/stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style3 {
     font-family: Verdana, Arial, sans-serif;
     font-size: 16px;
     font-weight: bold;
     color: #FFFFFF;
.style4 {color: #FFFFFF}
-->
</style>
</head>
<body>
<p> </p>
<p> </p>
<p>
<%
          String mMtId ="";
          String cCode="";
          String dDesc ="";
          String sStatus="";
          String mtId =request.getParameter("MtId");
          System.out.println("mtId is " + mtId);
%>
</p>
     <%
                         Display display = new Display();
                         ArrayList list = display.getValueById(mtId);
                         if(list.size() > 0)
                                   for(int x = 0; x<list.size(); x++)
                                        Tay myshop = (Tay)list.get(x);
                                        mMtId = myshop.getMtId();
                                        cCode = myshop.getChargeCode();
                                        dDesc = myshop.getDescription();
                                        sStatus =myshop.getStatus();
     %>
<form action="update.jsp" method="post" name="form" id="form">
<p> </p>
<table width="91%" border="1" align="center" cellpadding="1" cellspacing="0">
<tr>
<td colspan="5" bgcolor="#FFCC66"><div align="center"><span class="style3">DEMO PROJECT </span></div></td>
</tr>
<tr>
<td width="15%"><span class="style2">CHARGECODE </span></td>
<td width="31%"><input name="chargeCode" type="text" class="boxText" id="chargeCode" size="25" maxlength="25" value="<%=cCode%>"></td>
<td width="12%" rowspan="2"><span class="style2">STATUS </span></td>
<td width="27%" rowspan="2"><span class="style1">Active</span>
<input name="sStatus" type="radio" value="A" checked>
<span class="style1">Closed</span>
<input name="sStatus" type="radio" value="C"></td>
<td width="15%"> </td>
</tr>
<tr>
<td><span class="style2">DESCRIPTION</span></td>
<td><input name="dDescription" type="text" class="boxText" id="description" size="70" maxlength="68" value="<%=dDesc%>"></td>
<td> </td>
</tr>
<tr>
<td colspan="5"><div align="right">
<input name="buttSave" type="submit" class="messageBox" id="buttSave" value="Save">
<input name="cmdExit" type="submit" id="cmdExit" value="Exit"onClick="exitPage()" />
</div></td>
</tr>
<tr>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">MtID</div></td>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">Charge Code </div></td>
<td colspan="2" bgcolor="#FFCC66"><div align="center" class="style1 style4">Description</div></td>
<td bgcolor="#FFCC66"><div align="center" class="style1 style4">Status</div></td>
</tr>
     <tr>
<td><%=mMtId%></td>
<td><%=cCode%></td>
<td colspan="2"><%=dDesc%></a></td>
<td><%=sStatus%></td>
</tr>
     <%
     %>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
<td> </td>
</tr>
</table>
</form>      
</body>
</html>
I am using mssql database.
Thanks for your anticipated response.
have a wonderful day,
taysay

I think what you have done is something you need to do at the Java Servlet level instead of at jsp level.
Even you can do in this way and if you want to extend this display usage then you need to use buttons, textfields for furthur processing.
Good Luck,
Narayana :-)

Similar Messages

  • Help using DataTags on Edit JSP Form

    I costumized the Edit JSP page using DataTags but I don`t know how to edit the current record.
    I have the source code of the first page:
    //Kssegtroles.jsp
    <%@ page language = "java" errorPage="errorpage.jsp" import = "java.util.*, oracle.jbo.*, javax.naming.*, oracle.jdeveloper.html.*, oracle.jbo.html.databeans.*" contentType="text/html;charset=ISO-8859-1" %>
    <%
    // make sure the application is registered
    oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "PrjSegJSP_PkgSeg_PkgSegModule");
    %>
    <HTML>
    <HEAD>
    <TITLE>INSTITUTO ECUATORIANO DE SEGURIDAD SOCIAL</TITLE>
    <LINK href="estilo/estilo.sty" rel=stylesheet type=text/css>
    </HEAD>
    <BODY class="clbody" aLink=#800000 bgColor=#ffffff leftMargin=0 link=#808000 text=#000000 topMargin=0 vLink=#c0c0c0>
    <jsp:useBean class="oracle.jbo.html.databeans.NavigatorBar" id="tb" scope="request" >
    <%
    tb.setTargetUrl("KssegtrolesView.jsp");
    tb.initialize(application,session, request,response,out,"PrjSegJSP_PkgSeg_PkgSegModule.KssegtrolesView");
    String sImageBase = "/webapp/images";
    tb.setImageDir(sImageBase);
    tb.addButton(tb.NAVIGATE_FINDFORM , "KssegtrolesView_Query.jsp");
    tb.addButton(tb.NAVIGATE_BROWSE , "KssegtrolesView_Browse.jsp");
    tb.addButton(tb.NAVIGATE_INSERT , "KssegtrolesView_Insert.jsp");
    tb.addButton(tb.NAVIGATE_EDIT , "KssegtrolesView_Edit.jsp");
    tb.render();
    %>
    </jsp:useBean>
    <br>
    <jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
    <%
    RowViewer.initialize(pageContext, "PrjSegJSP_PkgSeg_PkgSegModule.KssegtrolesView");
    RowViewer.setReleaseApplicationResources(true);
    RowViewer.render();
    %>
    </jsp:useBean>
    </BODY></HTML>
    This is the code for the Edit Page:
    //KssegtrolesView_Edit.jsp
    <%@ page language = "java" errorPage="errorpage.jsp" import = "java.util.*, oracle.jbo.*, javax.naming.*, oracle.jdeveloper.html.*, oracle.jbo.html.databeans.*" contentType="text/html;charset=ISO-8859-1"%>
    <%
    // make sure the application is registered
    oracle.jbo.html.jsp.JSPApplicationRegistry.registerApplicationFromPropertyFile(session , "PrjSegJSP_PkgSeg_PkgSegModule");
    %>
    <HTML>
    <HEAD>
    <TITLE>INSTITUTO ECUATORIANO DE SEGURIDAD SOCIAL</TITLE>
    <LINK href="estilo/estilo.sty" rel=stylesheet type=text/css>
    </HEAD>
    <BODY class="clbody" aLink=#800000 bgColor=#ffffff leftMargin=0 link=#808000 text=#000000 topMargin=0 vLink=#c0c0c0>
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <jbo:ApplicationModule configname="PkgSeg.PkgSegModule.PkgSegModuleLocal" id="PkgSegModule" username="iessuser" password="iess" />
    <jbo:DataSource id="dtsRoles" appid="PkgSegModule" viewobject="KssegtrolesView" ></jbo:DataSource>
    <jbo:Row id="Row" datasource="dtsRoles" action="Current" ></jbo:Row>
    <form name="KssegtrolesView_form" action="KssegtrolesView_SubmitEditForm.jsp">
    <table border="0">
    <tr>
    <td>Codigo de rol</td>
    <td>
    <jbo:InputText datasource="dtsRoles" dataitem="Codrol"/>
    </td>
    </tr>
    <tr>
    <td>Descripcisn del rol</td>
    <td>
    <jbo:InputText datasource="dtsRoles" dataitem="Desrol"/>
    </td>
    </tr>
    <tr>
    <td>Creacisn de Usuario</td>
    <td>
    <jbo:InputText datasource="dtsRoles" dataitem="Creusuper"/>
    </td>
    </tr>
    </table>
    <input name="MyRowKey" type="hidden" value="<jbo:ShowValue datasource="dtsRoles" dataitem="RowKey"/>" />
    <br>
    <input type="submit" value="Update"/>
    <input type="reset" value="Reset"/>
    </form>
    </BODY>
    </HTML>
    <jbo:ReleasePageResources releasemode="Stateless" />
    When I execute this, I am not in the current record that I edit, it returns me the information of the first record.
    Could you help me please?
    null

    I suppose that your two pages don't use same application module instance. It's the matter of mixing use of DataTags and WebBeans. Search this forum with these search words; "DataTag" and "WebBean".

  • Calculations in Jsp form - Urgent Please

    Hi,
    I have 3 fields in my table, Quantity,Price and Total. Quantity * Price gives Total. Price is the Column of another table and I display the values of Price using <jbo:InputSelectLOV>. So,my requirement is when I input the value for Quantity and select the values from list in the Edit.jsp form I need the value of Quantity * Price to be displayed in the Total field on Browse form. Could someone please help me. I am new to JSP and any help is appreciated.
    Thank You

    It's not related to JDeveloper this is a generic thing for HTML pages - if you want to do client side (menaing no traffic to the server) actions you use Javascript.
    You just need to stick the Javascript into the JSP page you have inside JDeveloper.

  • How to find table name and field name in JSP FORM

    Hi
    In JSP form's like XML publisher responsibility>templet
    In that form how can we see the system-last query . and how to see the table name

    hi yamini,
    plz go to help->record history (for fining table name)
    and
    help->diagnostic->examine (for finding field name)& enter last_query
    in JSP form also same above only i think.
    or check in back end & apply who columns
    Edited by: raghava bandi on Nov 7, 2008 2:05 AM

  • How to redirect from list edit form to another page using jquery in sharepoint 2013

    hi friends i have been trying to find a way to redirect from list edit form to another page using javascript and jquery
    i found lot of codes online but non of them are working for me.
    what i need is i have to save the data in the form and after that it has to redirect to another page. it has to get the url from hyperlink field of the item.
    please help me in this regards

    Not sure if you have gone through below links:
    http://spservices.codeplex.com/wikipage?title=%24().SPServices.SPRedirectWithID
    http://blogs.askcts.com/2013/02/18/using-spservices-and-jquery-to-perform-a-redirect-from-a-sharepoint-list-newform-to-editform/
    Please ensure that you mark a question as Answered once you receive a satisfactory response.

  • How to populate List Item from the table in a form builder

    I want to know how to populate the List Item (pop up menu and combo box) from a table.
    Supposing I have a table Customer(cust_id,cust_name)
    and now I want to populate it in such a manner that I can update the data back to the database and also access the list on the form.

    This is the method i am using to populate a list.
    1- First of all you need to create a non-database list item for customer_name.
    2-create this procedure
    PROCEDURE populate_list_with_query
    --Populates the given list item with the specified query.
    (p_list_item in VARCHAR2
    ,p_query in VARCHAR2)
    IS
    /* Name the record group after the list item (no
    block prefix). */
    cst_rg_name constant VARCHAR2(30) :=
    GET_ITEM_PROPERTY(p_list_item,item_name);
    v_rg_id RECORDGROUP;
    BEGIN
    v_rg_id := FIND_GROUP(cst_rg_name);
    IF ID_NULL(v_rg_id) THEN
    v_rg_id := CREATE_GROUP_FROM_QUERY(cst_rg_name,p_query);
    END IF;
    IF POPULATE_GROUP(v_rg_id) = 0 THEN
    POPULATE_LIST(p_list_item,v_rg_id);
    /* Force display of first list element label
    in the list item. */
    COPY(GET_LIST_ELEMENT_VALUE(p_list_item,1),p_list_item);
    END IF;
    END populate_list_with_query;
    3- Create When-Create-Record on the block level and write this code
    BEGIN
    POPULATE_LIST_WITH_QUERY('bk1.customer_name',
    'SELECT customer_name, to_char(customer_id) FROM customer');
    END;
    In this example, the customer name is the (visible) list label and the customer ID is the (actual) list value
    i hope this will solve your problem ...

  • Inserting data from jsp form to multiple tables !

    Hi,
    I want to insert data from jsp form to two tables
    tables are
    (1) Form
    formId (PK)
    deptName
    (2) Data
    formId (FK)
    sNo
    description
    itemCode
    and the problem is that i want to save information form a jsp form to above two tables and i have only one form.
    so how do i insert data from a jsp form to multiple tables.

    You already know what your form in the jsp will be and what fields they are. You also already know what your database looks like. Using one form, you should be able to break the data down, and give it certain ids and/or names, so that when the form is submitted, you retrieve the correct values corresponding to a specific field and insert it.
    Unless there is something else I am not catching, this seems pretty straight forward.

  • The edit JSP page does not appear...

    Hi!
    I make a simple JSF application, I would like to show a DB table in a h:dataTable component and edit a given row after click, but the edit JSP page does not appear. I click the on link in the table, but the list is loaded again and not the edit page...:(
    (no exception in application server console)
    Please help me!
    my code:
    **************************************** listmydata.jsp***************************
                   <h:dataTable
                             value="#{myBean.myDataList}"
                             var="myDataItem"
                             binding="#{myBean.myDataTable}"
                   >
                        <h:column>
                             <f:facet name="header">
                                  <h:outputText value="Ajdi"/>
                             </f:facet>
                             <h:commandLink action="#{myBean.editMyData}">
                                  <h:outputText value="#{myDataItem.id}"/>
                             </h:commandLink>
                        </h:column>
    ********************************* MyBean.java *******************************
    package bean;
    import java.sql.Connection;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.component.html.HtmlDataTable;
    import javax.faces.context.FacesContext;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    import wrapper.MyData;
    public class MyBean {
         private List myDataList;
         private HtmlDataTable myDataTable;
         private MyData myDataItem;
         protected Connection Conn;
         // *********************** actions ***********************
         public String editMyData() {
              myDataItem = (MyData)getMyDataTable().getRowData();
              return "editmydata";
         public String saveMyData() {
              try {
                   updateDataInDB();
              catch (SQLException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              catch (NamingException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              return "listmydata";
         // *********************** setter ***********************
         public void setMyDataList(List myDataList) {
              this.myDataList = myDataList;
         public void setMyDataTable(HtmlDataTable myDataTable) {
              this.myDataTable = myDataTable;
         public void setMyDataItem(MyData myDataItem) {
              this.myDataItem = myDataItem;
         // *********************** getter ***********************
         public List getMyDataList() {
              if (myDataList == null || FacesContext.getCurrentInstance().getRenderResponse()) {
                   loadMyDataList();
              return myDataList;
         public HtmlDataTable getMyDataTable() {
              return myDataTable;
         public MyData getMyDataItem() {
              return myDataItem;
         // *********************** others ***********************
         public void loadMyDataList() {
              try {
                   getDataFromDB();
              catch (NamingException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
              catch (SQLException e) {
                   System.out.println(e);
                   System.err.println(e);
                   e.printStackTrace();
         void getDataFromDB() throws NamingException, SQLException {
              myDataList = new ArrayList();
              java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement("SELECT id, name, value FROM BEA_JSF_SAMPLE");
              PreStat.execute();
              java.sql.ResultSet Rs = PreStat.getResultSet();
              while(Rs.next()) {
                   MyData OneRecord = new MyData();
                   OneRecord.setId(Rs.getLong(1));
                   OneRecord.setName(Rs.getString(2));
                   OneRecord.setValue(Rs.getString(3));
                   myDataList.add(OneRecord);
         void updateDataInDB() throws SQLException, NamingException {
              String sql = new String("UPDATE BEA_JSF_SAMPLE SET name=?,value=? WHERE id=?");
              java.sql.PreparedStatement PreStat = ownGetConnection().prepareStatement(sql);
              PreStat.setString(1,myDataItem.getName());
              PreStat.setString(2,myDataItem.getValue());
              PreStat.setLong(3,myDataItem.getId().longValue());
              PreStat.execute();
              ownGetConnection().commit();
         Connection ownGetConnection() throws SQLException, NamingException {
              if (Conn == null) {
                   InitialContext IniCtx = new InitialContext();
                   DataSource Ds = (DataSource)IniCtx.lookup("JDBCConnectToLocalhost_CRS");
                   Conn = Ds.getConnection();
              return Conn;
    ******************************* editmydata.jsp *****************************
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <html>
    <body>
    <f:view>
    <h:form>
         <h:panelGrid columns="2">
              <h:outputText value="Name"/>
              <h:inputText id="name" value="#{myBean.myDataItem.name}"/>
              <h:outputText value="Value"/>
              <h:inputText id="value" value="#{myBean.myDataItem.value}"/>
         </h:panelGrid>
         <h:commandButton action="#{myBean.saveMyData}" value="Save"/>
    </h:form>
    </f:view>
    </body>
    </html>

    I have put his lines in the faces-config.xml and now it works:
         <navigation-rule>
              <from-view-id>*</from-view-id>
              <navigation-case>
                   <from-outcome>editmydata</from-outcome>
                   <to-view-id>editmydata.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
         <navigation-rule>
              <from-view-id>*</from-view-id>
              <navigation-case>
                   <from-outcome>listmydata</from-outcome>
                   <to-view-id>listmydata.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    I don't understand, that I define the next JSP page in the bean java file, which must be shown, but I must define this in the faces-config.xml as well.
    for example:
         public String editMyData() {
              myDataItem = (MyData)getMyDataTable().getRowData();
              return "editmydata";
    is it right or Do I make a mistake somewhere?

  • How to capture the data from a JSP form

    Hi
    I have a JSP form, My task is to capture the data from a JSP and submit to Data Base. for example I have the field like
    Enter Table name to be created in data base: The table name is to be captured by a servlet and by that table name, table should be created in the data base.
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????
    Edited by: Reddy_Prasad on ?? ?????, ???? ?:?? ???????

    Get the entered value from the jsp into servlet using request.getParameter("enteredTableName"). it will return the String,pass this table name to execute query using JDBC connection and statement objects.
    -cheers Ram

  • Saving data in database from jsp form

    I have a very huge table in my jsp...600 entries.
    my form table is like this.
    the number of rows depends upon the number of days in a month.
    there is one colum which specifies the time frame in 1 hr frame and
    withing each column is two coulmn representing either male or female.
    If i want to save the data entered in the form to database synchronizing
    with date, timeframe and sex, what is the best way to do it?
    I did it in a way that declaring 600 private string variables in form bean,
    saving it in a list and sending it to database.
    Is there any other way of doing it without the need for 600 getter and setter methods?

    I just want to see if I understood this correctly. You declared 600 private variables in a form bean?
    Perhaps this is not the best use of either Struts or the JavaBean specification. What you almost certainly actually have is a series of homogenous objects. Store that instead in an array or Collection. Use loops to iterate through the values to generate your table. There are both JSTL tags and plain Java code embedded within a JSP to achieve this task.
    - Saish

  • How to iterate List in jsp without using for loop

    Hi,
    I am developing a small application is struts. I have one ActionForm file which contain one List like getEmployeeDetailsList(). When I am using this list in jsp page for displaying data. I want to display it as employee name, employee address, employee designation and employee contact no. These all fields are available in the above list. Now what is the problem is that I am using logic:iterate method to iterate data. but this is not sufficient to display all records in order. like employee name should be in one table and they can be vertical not horizontal, employee address is also should be seperate. and same thing with employee designation and contact no. I don't want to use for loop to iterate this list. Please tell me about optionCollection for this list. only employee names should be one drop down and employee designation is also in another drop down.
    Please help. It is really urgent.
    Any help will be appreciated.
    Thanks in advance.
    Manveer

    I'm not sure what you problem is, but one thing you can do is to create a new class and pass the list into its constructor (and store it as a private variable). Then, provide a set of functions in the new class that extracts data from the list and returns it in a form that the various parts of the JSP page wants. For example, one function may return a sorted list of just the employee names. In this way, all the business logic for formatting the data into a form that JSP page likes is hidden inside the new class.

  • Closing a Enumerated DropDown List in Adobe form

    I have an adobe form where we used Enumerated Drop down Lists for search helps. The problem is right now we dont have option to close the Enumerated DropDown List. It closes when we select a value or sometimes if we try "ESC" key. But we want to have a "Close"/"X" button like in normal search help.
    Letme know if there is any solution or an Alternate way to close the Enumerated Drop Down List from Adobe Form by just hitting a close/X button. Each value help has over 500 values, so we cannot use normal dropdowns, letme know if any other suggestions.
    Edited by: Phani Rajesh Mullapudi on Jun 21, 2010 8:14 PM

    Hello Arafat,
    I am using a drop down list in Adobe Interactive Form for Web Dynpro ABAP.
    The form is of ZCI type layout and the form interface is of XML schema-based interface type and the XML schema source is set to "Generated".
    I have included the following code in WDDOINIT method of the view:
    data: handle1 type ref to if_wd_context_node,
    begin of zstruct,
    zktokd type kna1-ktokd,
    end of zstruct,
    zitab type table of zsttxecr.
    handle1 = wd_context->get_child_node( name = 'DATA.NODE1' ).
    select ktokd from kna1 into corresponding fields of zstruct.
    append zstruct to zitab.
    endselect.
    handle1->bind_table( new_items = zitab ).
    In the Adobe Form Designer, i have binded the node NODE1 to the enumerated drop down list from native web dynpro library. Still the drop down box is not getting populated.
    Please let me know what is missing.
    Thanks and Regards.

  • How 2 disply 2 or More coulmns from the DBase to Dropdown list in JSP

    Dear Friends,
    Please can anyone help us, on displaying the 2 or more columns into a single Dropdown list in the JSP page, by using Struts-tag Libraries
    We are displayig only 1 coulmn from the DBase resultset to Dropdown list,
    When we try to concatenate, 2 columns of the resulset, the data format has changed
    Please help, Early response is appreciated
    Thanking you
    Jagadish

    WE are using sturts , Fallowing is code for
    extracting the O_NOUN and O_MODIFIER table Columns from the DBase and setting into
    "mat_Reg_ActionForm" form
         Statement stmt = null;
         ResultSet rs = null;
         ArrayList objQualList = new ArrayList();
         String query = " SELECT UNIQUE O_NOUN , O_MODIFIER FROM O_NOUN_MOD ";     
         stmt = conn.createStatement();
    rs = stmt.executeQuery(query);
         String columnLabel = (rsmd.getColumnName(0)+"|"+rsmd.getColumnName(1));
         String columnLabel = "Object"+"|"+"Modifier";
         objQualList.add(columnLabel);
         while(rs.next())
         String objModifier = (rs.getString("O_NOUN")+"|"+rs.getString("O_MODIFIER"));     
         objQualList.add(objModifier);
         mat_Reg_ActionForm.setObject(objQualList);
    Fallowing the iteration with which we are displaying the data in the Drop downl List
    "mat_Reg.jsp"
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html>
    <head><title></title>
    </head>
    <body>
    <html:form action="mat_Reg.do" name="mat_Reg_ActionForm" type="com.pilog.bo.ManfPartNoActionForm">
         <html:select name="mat_Reg_ActionForm" property="object">
              <html:options name="mat_Reg_ActionForm" property="object"/>
         </html:select>
    </TR>
    </TABLE>
    </html:form>
    </body>
    </html>
    Is this code will help you give us some guidence ! Your early reply will be appreciated
    Thankng you

  • How to retrieve datas from database to dropdown list in jsp

    hai.
    please tell me how to retrieve a perticular field list from database to a drop down list using jsp. i am new to jsp. i am doing employee management system. in that i need to edit employee's details as like.
    so that i want to display employee id's in a drop down list. i want to retrieve from database and display.
    please help me in this .
    advance thanks.

    Hello friendz,
    If tht is the i wud suggest if guyz can go wid AJAX...
    try to make use of xmlHttp Object and generate a new dependent drop down by using a property from a bean->servlet->VIEW(FORM)
    else save the form state in a session and then refersh it. once all in again.
    i had a similar problem which i solved in the following way
    Hi friend,
    I had a similar situation and i tried to solve it by using XmlHttpRequest Object(used in AJAX).
    U can checkout the below example just for further reference delete
    UserForm.jsp:
    ==========
    <head>
    <script>
    var xmlHttp
    function showState(str)
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    alert ("Browser does not support HTTP Request")
    return
    var url="getState.jsp"
    url=url+"?count="+str
    url=url+"&sid="+Math.random()
    xmlHttp.onreadystatechange=stateChange
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    function stateChange()
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
    document.getElementById("state").innerHTML=xmlHttp.responseText
    </head>
    <body>
    <select name='country' onchange="showState(this.value)">
    <option value='india>india</option>
    </select>
    <br>
    <div id='state'>
    <select name='state' >
    <option value='-1'>pickone</option>
    </select>
    </div>
    </body>       
    getState.jsp
    ============
    <%@page language="java" import ="java.util.Hashtable" import ="java.util.Set" %>
    <%
    String country=request.getParameter("count");
    response.setContentType("text/html");
    response.setHeader("Cache-Control","no-cache");
    try{
    Hashtable ht = (Hashtable)session.getAttribute("<ATTRIBUTE_NAME>");
    String buffer="<select name='state'><option value='-1'>Pick One</option>";
    Set s=ht.keySet();
    Object keys[]=s.toArray();
    int size=keys.length;
    for(int i=0; i < size;i++){
    buffer=buffer+"<option value='"+ht.get(keys).toString()+"'>"+ht.get(keys).toString()+"</option>";
    buffer=buffer+"</select>";
    response.getWriter().println(buffer);
    catch(Exception exp){
    response.getWriter().println(exp);
    %>

  • Multiple servlet actions from jsp forms

    Hi all ,
    how can i do muliple actions from a jsp form, i need to do an action when user clicks on a column and a different action when user clicks on cell in a row .
    i need to read and store the attribute from the column to pass back to the webservice to request that the service sorts the reults by that column either as desecending or as asending.
    also i need to get the value from a cell that is clicked on and pass that through as a parameter to the webservice to request some further data for the specific id.
    how can i do this?
    currently i have a form which has as part of the row an onclick event that captures the value of cell clicked - but what i need to do is change the cell value to a href and if this is clicked capture the value of the href and submitt this to the form action and regonise that the href has been clicked (how do i do that?) and thus do soemething specific for that in the servlet and if the column with its ascending or descending image is clicked capture the asc or desc value and regonise that the column asc or desc has been clicked (how do i do that?) and thus do soemething specific for that in the servlet.
    <tr onclick="selectPatCareRec(this)">
    <td><netui:label value="{container.item.perId}"/></td> rest of form is :-
    you dont need to pay attention to rest of stuff except that which columnHeader field was clicked and in which order (ie ascending or desc)
    also if a cell is clicked to pass the values as part of a submit to the action and regonise that a herf click was done and value of that cell - i have the javascript that is used to find the cell value once the row is clicked.
    <netui:form action="refresh">
          <rpb:repeaterBlock name="contacts" filter="<%=filter%>"
          ascendingImage='<%=request.getContextPath()+"/resources/images/up-arrow.gif"%>'
          descendingImage='<%=request.getContextPath()+"/resources/images/down-arrow.gif"%>'>
          <netui-data:repeater dataSource="{pageFlow.carerGpListResults}">
         <netui-data:repeaterHeader>
           <table class="tablebody" border="0">
             <tr>
               <th><rpb:columnHeader field="SYSTEMREF"></rpb:columnHeader></th>
               <th><rpb:columnHeader field="TITLE"><i18n:getMessage messageName="title"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="GIVENNAME"><i18n:getMessage messageName="given_name"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="FAMILYNAME"><i18n:getMessage messageName="family_name"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="ADDRESS"><i18n:getMessage messageName="address"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="POSTCODE"><i18n:getMessage messageName="post_code"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="DOB"><i18n:getMessage messageName="dob"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="ORGANISATION"><i18n:getMessage messageName="organisation"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="TYPE"><i18n:getMessage messageName="type"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="QUESTION"><i18n:getMessage messageName="question"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="ANSWER"><i18n:getMessage messageName="answer"/></rpb:columnHeader></th>
              <th><rpb:columnHeader field="PER_ID"><i18n:getMessage messageName="patientid"/></rpb:columnHeader></th>
             </tr>
           </netui-data:repeaterHeader>
           <netui-data:repeaterItem>
             <tr onclick="selectPatCareRec(this)">
               <!-- do an on click event to trigger another action to get all the patient list (ie. link it to the patientCasesList jsp) of cases and keep refresh to get sorting -->
              <td><netui:hidden dataInput="{container.item.SYSTEMREF}"dataSource="{actionForm.systemref}"/></td>
              <td><netui:label value="{container.item.TITLE}"/></td>
              <td><netui:label value="{container.item.GIVENNAME}"/></td>
              <td><netui:label value="{container.item.FAMILYNAME}"/></td> 
              <td><netui:label value="{container.item.ADDRESS}"/></td>
             <td><netui:label value="{container.item.POSTCODE}"/></td>
            <td><netui:label value="{container.item.DOB}"/></td>
            <td><netui:label value="{container.item.ORGANISATION}"/></td>
            <td><netui:label value="{container.item.TYPE}"/></td>
            <td><netui:label value="{container.item.QUESTION}"/></td>
           <td><netui:label value="{container.item.ANSWER}"/></td> 
              <td><netui:label value="{container.item.perId}"/></td> 
            </tr>
           </netui-data:repeaterItem>
           <netui-data:repeaterFooter></table></netui-data:repeaterFooter>
         </netui-data:repeater>
         <br />
         <rpb:firstPage label="First"/>
         <rpb:previousPage label="Previous"/>
         <rpb:nextPage label="Next"/>
         <rpb:pageNumber/>
          </rpb:repeaterBlock>
            <div>
            <netui:hidden tagId="selectedPatientId" dataSource="{actionForm.selectedPatientId}" dataInput="{actionForm.selectedPatientId}" />
            </div>
        </netui:form>thanks for any / all help.

    You can modify your connection pool management servlet so you can set the 'connection pool object' as an attribute of the request. Then forward the request to your jsp page.
    Example:
    in your service method of your sevlet, add something like
    public void service (HttpServletRequest request, HttpServletResponse response) {
    ConnectionPool pool= new ConnectionPool();
    request.setAttribute("mypool", pool);
    // forward the request to a jsp page.
    RequestDispatcher dispatcher = request.getRequestDispatcher("jsp/myjsp.jsp");
    dispatcher.forward(request, response);
    }then in your myjsp.jsp, you can access the connection pool object using the 'mypool' attribute.

Maybe you are looking for

  • Can't install iTunes9 on windows 7

    Got new iPod nano for xmas and now i can't download iTunes to use it! I tried every possible solution offered on the support sites and nothing is working.... when i start the download it will freeze and random stages of the process.....some times 29%

  • Oracle SQL Developer 2.1 EA1 and 1.5.5 not working on MacOS X Snow Leopard

    Currently, the Oracle SQL Developer 2.1 EA1 and 1.5.5 are not working on MacOS X Snow Leopard. Is there a plan to support the actual version of OS X? When I try to start the MacOS X-Download I always get the following errors using MacOS X 10.6.1: ./s

  • Running programs won't stay minimized

    Hi, I have a MacBook Pro (15-inch, Mid 2009) (2.66 GHz Intel Core 2 Duo, 4 GB 1067 MHz DDR3) that I just upgraded to Yosemite. Since upgrading, whenever I minimize apps back into the Dock, after a few seconds my desktop background will flash to black

  • How many computers can synch to Apple TV?

    I have 3 macs in the house. Can all 3 "publish" videos, photos, etc to apple tv? Or can only one computer be synched?

  • Internet Trouble W. Service Provider ( I.O.)

    So i have IO Digital Cable As My Internet & Cable provider. The internet was installed into my home pc desktop but i frequently used to switch the Ethernet Jack and plug it into my Mac Book Pro to use internet on my laptop. Now as of late i've not be