Displaying a list in JSP

Hi guys,
I'm struggling to find any examples of how to display a list of data in a custom JSP page. I will have some type of holding object to contain an array of BPM Objects. I would like to display one table row in the JSP for each object.
Does anyone have any examples of what format the instance variable should be and how i can map this into the attributes and iterate over this in the JSP.
thanks!
Neil

Here is some js code that calls the method 'getByRegion' on the myInfo view object, that I had passed into the jsp. Here is an example of how to populate a Dropdown list in the jsp, with the returned values... Its not on the same line as what you wanted, but will give you an example of using ajax to call a bpm method.
function regionSelect(regionValue){
     var sel = document.getElementById("entity");
     sel.options.length=0;
     var myurl = '<f:invokeUrl var="myInfo" methodName="getByRegion"/>';
          $.get(myurl, {name: regionValue}, function(data){
               for(i=0; i<data.length;i++){
                    sel.options=new Option(data[i].key + ' - ' + data[i].value,data[i].key, false, false);
          }, "json");
And the BPM Method code:  Note, its returning a JSON string here.
This takes a java.util.map (requestParams) as an input argument.inAr as String[] = String[](get(requestParams, arg1 : "name"))
inVal as String = toLowerCase(inAr[0])
entity as String[]
entityId as String[]
sql as String = "select ENTITY_ID, ENTITY_DESC from vm_opts_coun_reg_entity where region = '" + toUpperCase(inVal) + "' order by entity_id"
for each row in executeQuery(DynamicSQL, sentence : sql, implname : "AppDB") do
     entity[] = String(row["ENTITY_DESC"])
     entityId[] = String(row["ENTITY_ID"])               
end
retString as String = "["
for i in 0..length(entityId)-1 do
     key as String = entityId[i]
     value as String = entity[i]
     retString = retString + "{\"value\" : \"" + value + "\",\"key\" : \"" + key + "\" },"
end
if length(retString) > 1 then
     retString = substring(retString, first : 0, last : length(retString)-1)
end
retString = retString + "]"
return retString
HTH!
-Kevin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How can I display a list of records from a JSP to my Midlet ??

    Hi there !
    I'm new in J2ME. I have been strugling with this problem for weeks now. All I find on the net is some theory and is not helping me much. Here the deal
    I have created a Midlet that shoud display a certain list which is from the remote database. The list comes from a JSP file in the server. When I use the browser I can see the list.
    The problem comes when I have to take the same list and output it in my midlet file. Then finding the selected index of the selecte item of the same list and using it somewhere else.
    I would appreciate it if somone could help me !!
    My head is speaning now !!! If you want me to post my code so one could identidy the proble, I don't mind !! Help please !!

    Here is my Code !!
                 String url = "http://10.2.25.3:8080/CreateAppointment/doctorsList.jsp";
        String dateUrl = "http://10.2.25.3:8080/CreateAppointment/date.jsp";
       String myUsername,myPassword;
       // Custom declaration code starts here
       public CreateAppointment_GUI()
                //Creating a login Form
                loginScreen = new Form("Login");
                //Login form Textfields
                username = new TextField("Username:", null, 200, TextField.ANY);
                password = new TextField("Password:", "Initial text", 200, TextField.ANY|     TextField.PASSWORD);
                loginScreen.append(username);
                loginScreen.append(password);
                //Adding the commands
                loginScreen.addCommand(loginCommand);
                loginScreen.addCommand(cancelCommand);
                loginScreen.setCommandListener(this);
                loginScreen.setItemStateListener(this);
                // Creating my selection list
                String[] selectionList = { "1.Appointments", "2.Add New Patient", "3.Patient Details" };
                listSelectAction = new List("Select Action", List.IMPLICIT, selectionList, images);
                listSelectAction.addCommand(backCommand);
                listSelectAction.addCommand(nextCommand);
                listSelectAction.setCommandListener(this);
             public void startApp() throws MIDletStateChangeException
               display = Display.getDisplay(this);
               display.setCurrent(loginScreen);
            public void pauseApp()
            public void destroyApp(boolean unconditional) throws MIDletStateChangeException
                 notifyDestroyed();
            public void itemStateChanged(Item item)
       void getDoctors(String url) throws IOException {
                    HttpConnection connection = null;
            InputStream is = null;
            OutputStream os = null;
            StringBuffer stringBuffer = new StringBuffer();
            TextBox textBox = null;
            String newStr =null;
            String newStr2=null;
            Vector v = new Vector();
           try {
              connection = (HttpConnection)Connector.open(url);
              connection.setRequestMethod(HttpConnection.POST);
              //connection.setRequestProperty(String key, String value)
              connection.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
              connection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.0");
              connection.setRequestProperty("Content-Language", "en-CA");
              connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
              os = connection.openOutputStream();
              is = connection.openInputStream();
              int ch;
              while ((ch = is.read()) != -1) {
                stringBuffer.append((char) ch);
                System.out.print((char)ch);
                   }//while
              newStr = stringBuffer.toString();
                    newStr2=newStr.trim();
                    int start = 0;
                    position = newStr2.indexOf("%", 0);
                    while ((position = newStr2.indexOf("%",start)) > -1) {
                      String aName = newStr2.substring(start,position);
                      v.addElement(aName); // store the substring
                      start = position + 1; // so the next time we start checking following the space
              String[] theNames = new String[v.size()]; // create an array big enough to store the strings
              v.copyInto(theNames); // Now theNames is a String array with the list of names
               // now we can create a List using this array:
               listDoctors = new List("Select Doctor", List.IMPLICIT, theNames,null);
               listDoctors.addCommand(backCommand);
               listDoctors.addCommand(nextCommand);
               listDoctors.setCommandListener(this);
          } //try
           finally {
               if(is!= null) {
                  is.close();
               } //if
               if(os != null) {
                  os.close();
               }//if
               if(connection != null) {
                  connection.close();
               }//if
            }//final
         display.setCurrent(listDoctors);
        } //invoke
    public void commandAction(Command c, Displayable d)
                     if (c == loginCommand)
                      myUsername = username.getString();
                      myPassword = password.getString();
                         Thread thread = new Thread() {
                               public void run() {
                                   try {
                                      getDoctors(url);
                                      display.setCurrent(listSelectAction);
                                   }// Try
                                   catch (IOException ioe) {
                                      ioe.printStackTrace();
                                   }// catch
                               }// Public void
                         };//Thread
                          thread.start();
                     else if (c == cancelCommand && d == listSelectAction)
                     else if (c == nextCommand && d == listSelectAction)
                        int selectedAction = listSelectAction.getSelectedIndex();
                            Alert displayNewText =
                            new Alert("Selected","Screens are still being developed", null, AlertType.INFO);
                                displayNewText.setTimeout(1000);
                         if (selectedAction == 0)
                             Thread thread = new Thread() {
                               public void run() {
                                   try {
                                      getDoctors(url);
                                      display.setCurrent(listSelectAction);
                                   }// Try
                                   catch (IOException ioe) {
                                      ioe.printStackTrace();
                                   }// catch
                               }// Public void
                         };//Thread
                          thread.start();
                         if (selectedAction == 1)
                               display.setCurrent(displayNewText);
                         if (selectedAction == 2)
                               display.setCurrent(displayNewText);
                     }//Else
                     else if (c == backCommand && d == listDoctors)
                          display.setCurrent(listSelectAction);
                     else if (c == nextCommand && d == listDoctors)
                             Thread thread1 = new Thread() {
                               public void run() {
                                   try {
                                      getDate(dateUrl);
                                      display.setCurrent(listDate);
                                   }// Try
                                   catch (IOException ioe) {
                                      ioe.printStackTrace();
                                   }// catch
                               }// Public void
                         };//Thread
                          thread1.start();
                     else if (c == backCommand && d == listDate)
                          display.setCurrent(listDoctors);
    }That is my midlet !! Now here is the code for my JSP !!
                        <%@ page import="java.sql.*" %>
    <%@page import="java.util.*,java.text.*" %>
    <%
    String name="";
    String id = "";
    String connectionURL = "jdbc:microsoft:sqlserver://10.2.25.223;DatabaseName=NDOH_PAAB";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <%
    try
                            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                    catch (Exception ex)
                            out.println(ex.toString());
                            connection = DriverManager.getConnection(connectionURL,"remotepaab_user","mohwiti2004");
                            statement = connection.createStatement();
                            String mysql ="SELECT * from physicians";
                            //out.println(mysql);
                            rs = statement.executeQuery(mysql);
    %>
    <%
          while (rs.next()) {
                 name= rs.getString("name");
                 id = rs.getString("id");
                 out.print(name + "%");
                 out.print(id + "%");
    %>
    <%
    %>
    <% rs.close(); %>In the JSP the name variable is the one that has my List. The problem is how do I say in my Midlet = display the list contained in name. Or in id. I need to use both of them "name + id". the id I will use to find out which name a user ha selected !! Not sure how !!!
    Any help would be appreciated !! Thanks !!

  • Display request contents in JSP page

    i need to display the contents in a request in my JSP.
    meaning:
    i have a hashmap (containing string and a list) coming from the EJB tier to struts action in an event response object, I'm sure that the request has these values. cuz i tested it in struts action using the following code:
    HashMap result = (HashMap)((EventResponseSupport)request.getAttribute(WebKeys.EVENT_RESPONSE)).getPayload();
    System.out.println("Sponsor name = " + result.get("sponsor"));I am able to print it in the console but i need to know how to display it in the jsp. i tried many things but i can't get it right.
    first i need to display the string and then i need to iterate through the list to display its contents in a table.
    any help would be appreciated.

    Kindly use JSP Scriplet to load the HashMap into the Page Context.
    Then you can use the Struts iterate tags to paint the contents of the HashMap

  • Duplicate rows displayed in list

    I am using ADF, Struts and JSP.
    On occasion, some of the pages that simply display a list of attibutes in a VO display duplicate rows - these views reference just one EO and in the majority of cases all of the default settings are used.
    There seems to be no consistency as to what causes this, at first it would appear after a new row had been inserted but then is would just appear when listing the detilas.
    If you refresh the list (event invokes executeQuery() to refresh the data from the DB) then the duplicate row goes away.
    This happens on my development machine (using JDev 10.1.2) and on the Application Server deployment.
    Has anyone esle seen this?
    Does anyone know why this might be happening and what I can do to solve this problem?
    Thanks
    Alan

    Marcos - thanks for the reply - this is the type of answer I was looking for since I'm not able to find anywhere in my code that I'm inserting a new row.
    However, I've tried this approach and am still experiencing the issue. I wanted to check that I had the right items checked / not checked. I don't have an item that says Disconnect Application Module 'unmanaged Release' - mine just says 'Release'. Here are my options (Jdev 10.1.3):
    (default unchecked) Failover Transaction State Upon Managed Release
    (default unchecked) Disconnect Application Module Upon Release
    (default checked) Support Dynamic JDBC Credentials
    (default checked) Reset Non-Transcational State Upon Unmanaged Release
    (default checked) Enable Application Module Pooing
    I've tried multiple combinations of checking / un-checking options (including having everything checked except the 2nd item above) and still get the same issue. I'm going to read up in the developer guide to see if I can understand these better.
    By the way, can you let me know which passivate state options you have set for your View Object that was showing the duplicate row but is now working? For example, right-click on VO, select edit - what items are checked on the Tuning tab?
    #1 Fill Last Page of Rows when Paging through Rowset
    #2 Passivate State
    #2a Including all Transient Values
    #3 Retain View Link Accessor
    Thanks

  • To show data( List of valueObjects   ,each vo contains List)using jsp tags

    I have set List in request attribute.
    List has value Object Class Objects.
    each value object contains get/set methods which get and set List of Strings and other get/set return and set Strings like:
    List getvaluesList()
    setValuesList(List list)
    String getLabel()
    setLabel(String st)
    My problem is how to show them in jsp using tags.
    ofcourse there will be drop down boxes in jsp with select options .

    Hi,
    According to your post, my understanding is that you wanted to display all the items that the logged-in users had created under each of the list in the site.
    I don’t think it’s a good idea to display all the items that the logged-in users had created under each of the list in the site in a visual web part.
    As we all known, different list has different fields, it will be different to display different list fields in a visual web part.
    If you still want to use the visual web part, I recommend you use the common fields that all the lists contained, suach as the Title, Createdy by, etc.
    Then query all the lists in the site by the created by field to compare with the current user.
    As a workaround, I recommend you use a page to display all the items that the logged-in users had created in the site.
    You can create a custom view based on current user for the lists, then add the lists web part in a page with the custom view.
    Now the page would only show the current users items.
    http://go.limeleap.com/community/bid/297846/Custom-List-View-Based-on-Current-User-Using-SharePoint-Designer
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/5e347dea-475e-4b95-8905-0f6e11bab7bf/sharepoint-list-filtering-by-current-user-or-group?forum=sharepointgeneralprevious
    What’s more, you can also use the target audience to achieve it.
    http://lixuan0125.wordpress.com/2012/06/18/audience-targeting-sharepoint-2010/
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • 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.

  • 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);
    %>

  • Plz: Any one who can show me how to iterate an list in jsp

    I had retrieved the data from the database setted into the bean class
    and i want to display the list on the jsp page (ie. i want to iterate a list)
    ........thanks

    ArrayList alist = new ArrayList();
    Iterator itr = alist.iterator();
    while(itr.hasNext())
    out.println(itr.next());
    tats it.............For a guy that doesn't knows how to call a method in another class that's very impressive :-D

  • 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 :-)

  • Urgent help needed: how to display a list of records on the screen

    Hello,
    This is very urgent. Can anyone help me. I have posted this query of mine before also but still no reply came. My whole application is dependent on this problem. Actually I am developing an application for mobile phone using MIDP. I have a record store which contains personal details for users. I am able to add records to the record store. Now I want that these records can be edited. For this I want to display a list of firstname field on the screen (and not console) so that i can select a user to edit its details. I have written the code to read the records and individual fields and display it on the console but i want to display that list on screen. I tried list and array but it s giving some error.
    I am giving the code to read the records below. Please tell me how can I display it in a list on the screen.
    public void readStream(){
    try
    byte[] recData=new byte[50];
    String varname;
    ByteArrayInputStream strmBytes = new ByteArrayInputStream(recData);
    DataInputStream strmData=new DataInputStream(strmBytes);
    if (rsperdt.getNumRecords() > 0){
    ComparatorString comp=new ComparatorString();
    int i=1;
    RecordEnumeration re=rsperdt.enumerateRecords(null, comp, false);
    while(re.hasNextElement()){
    rsperdt.getRecord(re.nextRecordId(), recData,0);
    System.out.println("Record #" + i );
    varname = strmData.readUTF();
    System.out.println("Name #"+varname);
    System.out.println("---------------------------");
    i=i+1;
    strmBytes.reset();
    comp.compareStringClose();
    re.destroy();
    strmBytes.close();
    catch(Exception e){
    System.err.println("read Records class:read");
    }

    I could not understand ur point "post the code in tags". I am pasting the code below. Please help as my whole application is stuck due to this problem and I have a deadline of 7th oct.
    This midlet is getting called from some other midlet.
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;
    import javax.microedition.rms.*;
    import java.io.*;
    import java.util.*;
    public class frmread extends Form implements CommandListener
    static final String rec_store="db_per";
    private RecordStore rsperdt=null;
    private Vector vecname;
    private ChoiceGroup chname;
    private boolean flagSortByPriority = false, flagShowPriority = true;
    private Form fmmain;
    private Command cmdBack;
    private teledoc midlet;
    public frmread(String title, teledoc midlet)
    super(title);
    this.midlet = midlet;
    openRecStore();
    this.setCommandListener(this);
         chname = new ChoiceGroup("new", Choice.EXCLUSIVE);
         vecname = new Vector();
         cmdBack = new Command("Back", Command.BACK, 1);
    fmmain = new Form("Record Search");
         addCommand(cmdBack);
    setCommandListener(this);
    readStream();
         rebuildTodoList();
         closeRecStore();
    * Process events for this form only
    protected void rebuildTodoList()
    for(int j=chname.size(); j>0; j--)
         chname.delete(j-1);
         int priority;
         todoitem item;
         String text;
         StringBuffer sb;
         for (int j=0; j<vecname.size(); j++)
              item=(todoitem) vecname.elementAt(j);
              priority = item.getPriority();
              text = item.getText();
              sb = new StringBuffer((flagShowPriority ? (Integer.toString(priority) + "-"): ""));
              sb.append(text);
              chname.append(sb.toString(), null);
    public void commandAction(Command c, Displayable s)
    if (c == cmdBack){
    midlet.displayteledoc();
    public void readStream(){
    try
    byte[] recData=new byte[100];
    String varname;
    int varname1=0;
         ByteArrayInputStream strmBytes = new ByteArrayInputStream(recData);
         DataInputStream strmData=new DataInputStream(strmBytes);
         if (rsperdt.getNumRecords() > 0){
    ComparatorString comp=new ComparatorString();
    int i=1;
              int id = 1;
              vecname.removeAllElements();
              RecordEnumeration re=rsperdt.enumerateRecords(null, comp, false);
    while(re.hasNextElement()){
         rsperdt.getRecord(re.nextRecordId(), recData,0);
    System.out.println("Record #" + i );
    varname = strmData.readUTF();
                   varname1 = strmData.readInt();
                   id = re.nextRecordId();
                   System.out.println("Name #"+varname);
                   todoitem item = new todoitem(varname1, varname, id);
                   vecname.addElement(item);
                   System.out.println("---------------------------");
                   i=i+1;
    strmBytes.reset();
              comp.compareStringClose();
              re.destroy();
    strmBytes.close();
    catch(Exception e){
    System.err.println("read Records class:read");
    public void openRecStore(){
    try{
    rsperdt=RecordStore.openRecordStore("db_per",true);
    catch(RecordStoreException e){
    db(e.toString());
    public void closeRecStore(){
    try{
    rsperdt.closeRecordStore();
    catch(Exception e){
    db(e.toString());
    public void db(String str){
    System.err.println("Msg:" + str);
    class ComparatorString implements RecordComparator{
    private byte[] recData = new byte[20];
    private ByteArrayInputStream strmBytes = null;
    private DataInputStream strmDataType = null;
    public void compareStringClose(){
    try{
    if(strmBytes != null)
         strmBytes.close();
    if(strmDataType != null)
         strmDataType.close();
         catch (Exception e)
    public int compare(byte[] rec1, byte[] rec2)
         String str1, str2;
         try {
              int maxsize = Math.max(rec1.length, rec2.length);
              if (maxsize > recData.length)
              recData = new byte[maxsize];
                   strmBytes = new ByteArrayInputStream(rec1);
                   strmDataType = new DataInputStream(strmBytes);
                   str1=strmDataType.readUTF();
                   strmBytes = new ByteArrayInputStream(rec2);
                   strmDataType = new DataInputStream(strmBytes);
                   str2=strmDataType.readUTF();
                   int result=str1.compareTo(str2);
                   if (result == 0)
                   return RecordComparator.EQUIVALENT;
                   else if (result < 0)
                   return RecordComparator.PRECEDES;
                   else
                   return RecordComparator.FOLLOWS;
                   catch (Exception e)
                   return RecordComparator.EQUIVALENT;

  • Displaying the list of values in the Report

    Hi All,
    Is there any possibility to include the scrollable list on the face of report(Not in the left side i.e as input control)
    For example If I have a country with different counties.
    Based on the country selection in the block it should display the list of counties as scrollable list.
    Would it be possible.
    Please help
    thanks
    Edited by: VP S on Sep 1, 2010 2:45 PM

    Not sure if you are looking for the same..
    Have you tried applying the filter at the filter pane..i.e.
    Click on the the show\hide filter pane (filter icon is present nearby the drill icon)
    Now drag the required object on this pane.
    It will create the dropdown filters on top of the report.
    Regards,
    Rohit

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

  • Display Image in another jsp

    hello,
    I am facing a design issue of so as to how to go about displaying an image which i am retrieving from database.
    I have a SubmitDoc.jsp which takes as input the doc id which i need to display looks like :
    *SubmitDoc.jsp*
    <FORM METHOD=POST ACTION="Retrieval">
    Enter Document ID to Retrieve: <INPUT TYPE=TEXT NAME=DOCID SIZE=20/><BR>
    <P><INPUT TYPE=SUBMIT></P>
    </FORM>I have my Retrieval servlet which access the DB and gets the binary stream for the image data based on DOCID.
    Now i try to forward result to a different jsp in order to display the binary data from the servlet.
    something like this :
    InputStream readImg = rs.getBinaryStream("DOCUMENT");
    response.setContentType("image/jpg");
    request.setAttribute("ImageData", readImg);
    // response.getOutputStream().write(rb,0,len);
    RequestDispatcher rd = request.getRequestDispatcher("DisplayDoc.jsp");
    rd.forward( request, response );What code should i put in DisplayDoc.jsp to show the image there.
    Any ideas how do i go about ?
    Thanks,

    What code should i put in DisplayDoc.jsp to show the image there.The same code you put in any html page to show an image:
    <img src="urlToDownloadImageFrom"/>In effect you have two requests.
    One for the JSP page, and then another for the image.
    So often what you find is the tag on your page needs to pass the id as well
    <img src="/ImageServlet?docId=abc123"/>

  • How to display uploaded image in jsp page.

    Hello,
    I am using struts 1.2.9 and and have uploaded image on the server. Now what I want to do display the image in jsp page after clicking on one link in jsp. I have tried many thing to display image in jsp page. But I am getting an error during displaying image in jsp. I have displayed absolute path in servlet. and used InputStream and outputstream to display image in jsp page.
    Can any one help.
    Thanks in advance
    Manveer Singh

    Follow this. This topic is very popular recently on the forum.

Maybe you are looking for

  • Document is in transfer for PO, creation not possible

    Hi We are using SRM 4.0 EC scenario. Recently we have been facing the subjected error 'Document is in transfer for PO, creation not possible' while making the confirmation in SRM. It is observed that this is happening mostly in case once we make GR a

  • Properties of the given BPM

    Hi friends, I am working on File --> RFC ---> File Scenario using BPM ... Here I am getting system error in BPM and showing broken red brick in workflow at sender1 ... I have given like this... Start --> Receiver ->sender1>Sender2 ---> Stop. I have g

  • Polish Language for N8

    Hi!, I´m new user and I´d like to know if I can to download the polish language and if I could to be use in my keyboard N8, many thanks.

  • Mavericks runs slow on MacBook Pro 2010

    A couple of weeks ago, I installed Mavericks OS X on my 15" MacBook Pro. Since then, it is running very slow: applications start up very slow, I often need to force quit them and Chrome is working extremely slow lately. I did an EtreCheck on my lapto

  • Right shift key

    When I press right shift key, it moves windows to edge of screen, how can I turn this off?