JSP: How do display list of objects in jsp table?

sorry that my question my confuse you, let me explain more.
in my java class, have method : public List retrieveAllVacancies(); and it returns a list of available vacancies.
on my jsp page, i want to display the vicancies in the table have 3 rows:
vacancy title  |  location  |  contract type
should i use some form of for loop or iterator to get the vacancies in the list? how does the jsp page get the list of objects?
anyone can help me? thanks

i found out the actual thing i look for is how to pass the vector to the jsp page.
<table>                                                                                                    
    <%
         Vacancy vacancy= new Vacancy();
        Vector allVacancies = new Vector();
        *//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
        if(allVacancies.size() == 0) 
            out.print("<br><br><br>     There are no vacancies available!!");
        else
    %>
    <tr>
        <td>Vacancy Title</td>
        <td>Contract Type</td>
        <td>Location</td>
    </tr>
    <%
        for (int i=0;i<allVacancies.size();i++)
            vacancy = (Vacancy)allVacancies.get(i);
     %>
    <tr>
        <td><% out.print(vacancy.getVacancyTitle());%></td>
        <td><% out.print(vacancy.getContractType());%></td>
        <td><% out.print(vacancy.getVacancyLocation()); %></td>
    </tr>
<%
%>
</table>*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
if i have this line, when i open the jsp page it will gives NullPoniterException.
the following was what i found for the similar problem,
You can add the Vector to the HttpSession with_
session.setAttribute(String name, Object value)_
or to the ServletRequest with_
request.setAttribute(String name, Object value)._
In the other JSP, retrieve the value with_
session.getAttribute(String name)_
or to the ServletRequest with_
request.getAttribute(String name)._
but i tried to do in this way it didn't work. for sure i didn't do it correctly. could anybody give bit more explanation about how to pass the Vector to the jsp page?
any help would be appreciated.

Similar Messages

  • How to display List of objects in jsp?

    Hi,
    I have a list containing Collection of bean objects.
    Now I want to display the values in the list of objects in a jsp using JSTL.
    Any body help me how to retrieve the bean objects from the List and how can i display that values in the jsp.
    Advanced Thanks,
    Mahendra

    Have you tried to use <:forEach></c:forEach> tag available in jstl?

  • How to display 'List' of objects in table format

    I am trying to display bunch of records in the table format.
    I have the List of bean object populated with table datas.
    Currently the code is working fine ,if I tend to display one record.I am wondering how to display all the records.
    I know theres a 'Fieldloop'.If thats the one please explain with example.

    iterate the object list using field loop. eg. is given below
    [      <Field name='MatchTable'>
    <Display class='SimpleTable'>
    <Property name='columns'>
    <List>
    <String>title</String>
    </List>
    </Property>
    </Display>
         <FieldLoop for='name' in='userlist'>
    <Field name='username'>
    <Display class='Label'>
    <Property name='labels'>
    <ref>name</ref>
    </Property>
    </Display>
    </Field>
         <FieldLoop>
         </Field>

  • How to display a pdf file in jsp

    hi,
    How to display a pdf file in jsp iam having a class which will return fileinputstream of the file object. the pdf file is in server.
    regards
    Arul

    A JSP is a combo of HTML and Java, so you can't really "display" a PDF file in a JSP.
    You can provider a href link to the PDF file in your JSP.
    You can use some utility package to read the contents of the PDF, pull certain things out of it, and display that in your JSP as html
    In a servlet you can set the content type to application/pdf and write the binary data of the PDF back to the browser. Once the browser finishes reading in the data it should open the PDF.

  • How to display List of Members

    Hi,<BR><BR>I would like to verify a calc script to check whether it return correct members,<BR>for example:<BR><BR>==============<BR>FIX(@REMOVE(@DESCENDANTS("TOTALOPERINCOME_05",0), @LIST(@UDA("GL Account", "TCACCOUNT"))))<BR><BR>ENDFIX<BR>==============<BR><BR>Can anyone advise how to display List of members from the above selection?<BR>The objective is to select level 0 descendants of "TOTALOPERINCOME_05", and remove the members if they have "TCACCOUNT" UDA.<BR><BR><BR>Thanks,<BR><BR>Norliansyah

    1) The log file is woefully inadequate for validating a list of more than a dozen or so members.<BR><BR>2) Creating a temporary database or application for this is like going from Dallas to Fort Worth by way of India.<BR><BR>3) Neither of the above check your syntax, only the selected elements.<BR><BR>Using member select: you have to rebuild the logic by using subset functionality, but you can both preview the list and generate the members in a useable form (although like I said, it doesn't check your syntax, just the functionality).<BR><BR>Using report generation: you have to replace the @relative with dimbot, and again it only validates the functionality if you successfully re-design the logic.<BR><BR>Overall, I believe the member select (using subset selection) is the quickest, easiest, and most useful.<BR><BR>-Doug.

  • In jsp how to display code?

    in jsp how to display some code like this:
    String body=body1;
    String body_new="";
    int Position = 0;
    while(true){
    int index = body.indexOf(0x0D, Position);
    if(index == -1){break;}
    if(index > Position){
    body_new += body.substring(Position, index);
    body_new += "<br>";
    Position = index +1;
    if(Position >= 0){
    body_new += body.substring(Position);
    body=body_new;
    ==================
    i find IE will not display the "<br>" and some char like "'"
    i use text textarea post
    thanks

    let us say this page as code.jsp
    code.jsp
    this is the u need to follow.........
    String body=body1;
    String body_new="";
    int Position = 0;
    while(true){
    int index = body.indexOf(0x0D, Position);
    if(index == -1){break;}
    if(index > Position){
    body_new += body.substring(Position, index);
    body_new += "<br>";
    Position = index +1;
    if(Position >= 0){
    body_new += body.substring(Position);
    body=body_new
    this is the sample usage ok

  • How to display list process, when i run sql*loader in c#

    Hello,
    How to display list process, when i run sql*loader in c#. I mean when i run sql*loader from cmd windows, i get list process how many row has been inserted. But when i run SQL*Loader from C#, i can't get process SQL*Loader.
    This is my code:
    string strCmd, strSQLLoader;
    string strLoaderFile = "XLLOAD.CTL";
    string strLogFile = "XLLOAD_LOG.LOG";
    string strCSVPath = @"E:\APT\WorkingFolder\WorkingFolder\sqlloader\sqlloader\bin\Debug\8testskrip_HTTP.csv";
    string options = "OPTIONS (SKIP=1, DIRECT=TRUE, ROWS=1000000,BINDSIZE=512000)";
    string append = "APPEND INTO TABLE XL_XDR FIELDS TERMINATED BY ','";
    string table = "OPTIONALLY ENCLOSED BY '\"' TRAILING NULLCOLS (xdr_id,xdr_type,session_start_time,session_end_time,session_last_update_time,session_flag,version,connection_row_count,error_code,method,host_len,host,url_len,url,connection_start_time,connection_last_update_time,connection_flag,connection_id,total_event_count,tunnel_pair_id,responsiveness_type,client_port,payload_type,virtual_type,vid_client,vid_server,client_addr,server_addr,client_tunnel_addr,server_tunnel_addr,error_code_2,ipid,c2s_pkts,c2s_octets,s2c_pkts,s2c_octets,num_succ_trans,connect_time,total_resp,timeouts,retries,rai,tcp_syns,tcp_syn_acks,tcp_syn_resets,tcp_syn_fins,event_type,flags,time_stamp,event_id,event_code)";
    strCmd = "sqlldr xl/secreat@o11g control=" + strLoaderFile + " LOG=" + strLogFile;
    System.IO.DirectoryInfo di;
    try
    System.Diagnostics.ProcessStartInfo cmdProcessInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe");
    di = new DirectoryInfo(strCSVPath);
    strSQLLoader = "";
    strSQLLoader += "LOAD DATA INFILE '" + strCSVPath.ToString().Trim() + "' " + append + " " + table;
    StreamWriter writer = new StreamWriter(strLoaderFile);
    writer.WriteLine(strSQLLoader);
    writer.Flush();
    writer.Close();
    // Redirect both streams so we can write/read them.
    cmdProcessInfo.RedirectStandardInput = true;
    cmdProcessInfo.RedirectStandardOutput = true;
    cmdProcessInfo.UseShellExecute = false;
    cmdProcessInfo.LoadUserProfile = true;
    //System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
    // Start the procses.
    System.Diagnostics.Process pro = System.Diagnostics.Process.Start(cmdProcessInfo);
    // Issue the dir command.
    pro.StandardInput.WriteLine(strCmd);
    // Exit the application.
    pro.StandardInput.WriteLine("exit");
    //Process[] processlist = Process.GetProcesses();
    //foreach(Process pro in processlist){
    Console.WriteLine("Process: {0} ID: {1}", pro.ProcessName, pro.Id);
    Console.WriteLine(pro.StandardOutput.ReadLine());
    // Read all the output generated from it.
    string strOutput;
    strOutput = pro.StandardOutput.ReadToEnd();
    pro.Dispose();
    catch (Exception ex)
    return;
    finally
    Thanks.

    friend
    sqlldr is an application residing in the OS. procedure runs in the dbms engine.
    you cannot run an os command directly from a procedure or a function or a package .
    If you want to do so you need to use either a daemon process created by a PRO*C program
    or a JAVA stored procedure to do so.
    just refer to previous question forums, you can find the solution. Somebody has already given a solution using
    java to run an OS command . check it out
    prakash
    [email protected]

  • How to Display IMAGE BLOB stored in a table in a html region APEX

    Need to know how to display an image stored in a table in a HTML APEX Region.
    Please

    Hi
    Please explain what you mean by it doesn't work?
    Are there errors messages, at what point, how far did you get and exactly what did you do????
    Please provide more information.
    Thanks
    Ben

  • How to display my ResultSet in a JSP??

    First off, I'm new to Java programming.
    Here's my problem. I have a set of users in my database. I'd like to retrieve all the user ID's (these are integers) from my User-table and display them in a JSP. Now, I realize that my coding below isn't very efficient as it's not exactly a MVC approach. I'm just trying to learn what a ResultSet is and how to manipulate it.
    I send my ResultSet to a JSP by "request.setAttribute("usersId", usersId);" but then I'm not sure what to do in my JSP to actually display my User ID's.
    My code:
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try {
    String dbURL = "jdbc:mysql://localhost:3306/heading360";
    String username = "root";
    String password = "";
    Connection connection = (Connection) DriverManager.getConnection(
    dbURL, username, password);
    Statement statement = (Statement) connection.createStatement();
    ResultSet userId = (ResultSet) statement.executeQuery("SELECT UserId FROM User");
    request.setAttribute("userId", userId);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/testUserId.jsp");
    dispatcher.forward(request, response);
    catch (SQLException e) {
    for (Throwable t : e)
    t.printStackTrace();
    }

    flukyspore wrote:
    OK thanks for the quick response.
    I am using using JSP EL to write my JSP's. Still learning JSTL.Bad idea. Learn JSTL.
    I understand everything you're saying, except I can't seem to find the exact approach to load my ResultSet into an object or collection. Could you give me an example of how to do that. My ResultSet is one column of User ID's, they are integers. Something like this:
    private static final String FIND_USER_ID_SQL = "SELECT USER_ID FROM USERS";
    private Connection connection;
    public List<Integer> findUserIds()
        List<Integet> userIds = new ArrayList<Integer>();
        Statement stmt = null;
        ResultSet rs = null;
        try
            stmt = connection.createStatement(sql);
            rs = stmt.executeQuery();
            while (rs.next())
                userIds.add(rs.getInt("USER_ID"));
        catch (SQLException e)
            e.printStackTrace();
        finally
            close(rs);
            close(stmt);
        return userIds;
    }Fill in the blanks.
    %

  • List of objects in Jsp

    Hi All,
    I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Now i am using
    <%List itemList = (List)session.getAttribute(Constants.ITEM); %>
    <%     for(int i =0;i<itemList.size();i++){
    NhopItemDef nhopItemDef= (NhopItemDef)itemList.get(i);
    if(nhopItemDef!=null){
    if(nhopItemDef.getItemType().trim().equals(Constants.BED_ZONE)){
    %>
    <tr >
    <td class="tb_dred_left_bf" height="30">
    <html:hidden property="item" value="<%=nhopItemDef.getItem()%>"/>
    <%=nhopItemDef.getItem()%>
    </td>
    Please let me know how to implement it using logic:iterate or c:foreach. which is the best way to implement?
    please provide some example codes here.
    Thanks & regards
    arullakshmi

    arullakshmi wrote:
    Hi All,
    I have list of object. each object has some fields. ex. item, type, zone. I want to retrieve it in jsp. Example:<c:forEach var="item" items="${itemList}">
      <tr>
        <td>${item.name}</td>
        <td>${item.type}</td>
        <td>${item.zone}</td>
      </tr>
    </c:forEach>For more information, check out a good [JSTL tutorial|http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL.html].
    ~

  • How to validate a session object in jsp?

    Hi All,
    i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
    function SetTimer(){
         //How long before timeout (should be a few minutes before your server's timeout
         //set timer to call function to confirm update
         if(timeoutMinutes)
         timerObj = setInterval("ConfirmUpdate()",60000);
    function clearTimerFn(){
              timerCount = 0;
              clearInterval(timerObj);
              //timerObj = setInterval("ConfirmUpdate()",60000);
    function ConfirmUpdate(){
         //Ask them to extend
         if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
              //load server side page if ok
              var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
              LoadXMLDoc(url);
    And in jsp i am calling this js function as
    <%session=request.getSession(false);
              if(session.getLastAccessedTime()==60000){ %>
              <script type="text/JavaScript">
         clearTimerFn();
    </script>
    <%}else{
    session.setMaxInactiveInterval(-1000);} %>
    could you pls help me out?

    The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
    see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
    If so, then the browser is caching the page, despite your attempts to stop it.

  • How to display URL of Trex on JSP

    Hi, Master:
    I am working on B2B Java part. on JSP:
    I need display where trex server located (URL) ie: http://lpaux001:50000, can I and how?
    Cheers,
    Eric

    Duplicate of thread Re: in B2B java, how can I find server url in JSP?
    Easwar Ram
    http://www.parxlns.com

  • How to display rows of data in JSP?

    Hi,
    I am learning Servlet and JSP. There is an exercise which requires us to access a database from a Servlet and display the retrieved data in a JSP.
    Now I am ok with the database connection. So how to display the data using some kind of loop?
    Regards

    They're called ResultSets and they are returned when you execute a query from a Statement. The next() method will tell you whether or not you have another row of data to read.

  • How to display record in hyperlink in JSP?

    Does any knows how to display the records in hyperlink? That's mean when I retrieve data from one database....two records...let's say peter and thomas....then i want the two records display in hyperlink....that's mean two records can be clicked by the user....and after the user clicked on either one of the record.....the record's value will be able to pass to the other page for use...
    Can anyone pls help me of this?Thank in advanced....

    This will pass the Value from the DB as Query Parameters to the Target JSP.
    Peter
    Thomas

  • How to access list box variable in jsp

    hi.......I'm new to jsp ...pls help me with the following.....i've created a form with some list boxes ,text boxes and radio buttons.....now i need to access the variables of these elements in order to validate and display them.....what is the syntax in jsp for accessing the list box variable(or txt box or radio button)
    tnx in advance.....

    You normally use a Servlet class for this. You can get request parameters by HttpServletRequest#getParameter() or #getParameterValues() then.
    This is fairly trivial though. Please go through a decent JSP/Servlet book/tutorial first.

Maybe you are looking for