Problem Displaying out Data in JSP

can anyone have a look at my code? i got some problems to display it in jsp when i run it with eclipse. can anyone help me on this?? did my java bean declared wrongly? thanks...
this is my java file
package com;
import java.io.File;
import com.db4o.Db4o;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
import org.jfree.chart.*;
import org.jfree.data.general.*;
public class StoreData{
     private static final long serialVersionUID = 1L;
     private final static String filename = "C:\\CountryPieChart.yap";
     public static void main(String[] args){
          //Delete the existing file
          new File(filename).delete();
          ObjectContainer db=Db4o.openFile(filename);
          try {
               StoreAllData();
               retrieveAllData();
          } finally{
               db.close();          //Close the database
     public static void StoreAllData() {
          //Delete the existing file
          new File(filename).delete();
          ObjectContainer db = Db4o.openFile(filename);
          //Add data to the database
          CountryPeople countryName_1 = new CountryPeople("Malaysia", 100);
          CountryPeople countryName_2 = new CountryPeople("New Z", 200);
          CountryPeople countryName_3 = new CountryPeople("UK", 300);
          CountryPeople countryName_4 = new CountryPeople("Thailand", 400);
          CountryPeople countryName_5 = new CountryPeople("Singapore", 50);
          //set the value to database
          db.set(countryName_1);
          db.set(countryName_2);
          db.set(countryName_3);
          db.set(countryName_4);
          db.set(countryName_5);
     public static void retrieveAllData() {
          //Open db
          ObjectContainer db = Db4o.openFile(filename);
          //Retrieve via empty object
          CountryPeople cName = new CountryPeople(null, 0);
          ObjectSet result = db.get(cName);
          DefaultPieDataset dataset = new DefaultPieDataset();
          //retrieve the data from database
          while(result.hasNext()) {
               CountryPeople obj = (CountryPeople) result.next();
               dataset.setValue(obj.getName(), obj.getValue());
               //System.out.println(result.next());
          //Create pie chart
          JFreeChart chart = ChartFactory.createPieChart(
                    "Sample Chart",
                    dataset,     
                    true,
                    true,
                    false);
          try {
               //save the pie chart as JPEG file
               ChartUtilities.saveChartAsJPEG(new File("C:\\CountryPieChart.jpg"), chart, 500, 300);
          } catch(Exception e) {
               System.out.println("Problem for creating chart");
and this is my jsp file
<jsp:useBean id="myStoreData" class="com.StoreData" scope="page"></jsp:useBean>
<html>
<head><title>Testing Displaying</title>
</head>
<body>
<b>Testing Display Page</b>
<img src="<jsp:getProperty name="myStoreData" property="getFileName" /> /">
</body>
</html>

<img src="<jsp:getProperty name="myStoreData" property="getFileName" /> /">
property="getFileName": There isnt such a property available in your bean.

Similar Messages

  • Displaying Mysql data in JSPs...

    I am having problem displaying results that I am pulling from a Mysql table. When I test the code in a Java environment it works absolutely fine but when I transfer the code to a JSP it seems to execute it correctly but not display the output on the screen. The code I'm using is as follows.
    <%
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn=DriverManager.getConnection(url,"root","111101");
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM student");
    while (rs.next()) {
    System.out.println(rs.getString("student_id")+"<br>");
    rs.close();
    catch( Exception x ) {
    x.printStackTrace();
    %>
    Any help on this topic would be much appreciated.

    My code now reads like this but I am still ahving the same problem -> I can't display the data being retrieved.
    <%@ page import="java.sql.*" %>
    <%
    String url = "jdbc:mysql://localhost/teaching";
    Statement stmt = null;
    ResultSet rs = null;
    %>
    <%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
    <html>
    <head>
    <%
    Class.forName("com.mysql.jdbc.Driver");
    Connection conn=DriverManager.getConnection(url,"root","111101");
    stmt = conn.createStatement();
    rs = stmt.executeQuery("SELECT * FROM student");
    while (rs.next()) {
    System.out.println(rs.getString("student_id")+"<br>");
    %>
    <%=rs.getString("student_id")%>
    <hr>
    <%
    rs.close();
    catch( Exception x ) {
    x.printStackTrace();
    %>

  • Displaying calculated data in JSP pages

    This is a general question about displaying data in JSP pages which has been calculated through ViewObj Routines. I have exposed the methods to the application level however, I want these methods to automatically run on the launch of the page. I can so this with a data action in the struts file. However, I have lots of these methods (all bringing single values of data), it seems inelegant to have 10 data actions or so. What's the best way to expose and show data on a JSP page automatically which has been calculated from the database rows.
    Thanks in advance

    You could convert the vo row to a hash using BeanUtils and then you could do what you want with it programmaticaly to automatically dissplay the lhash values.

  • Display current date in jsp?

    I hate asking for code, but I can't find anything on this. I'm trying to display the current date in the format YYYYMMDD on a jsp page without using scriplets. I've seen getting the time in milliseconds used through
    <jsp:useBean id="now" class="java.util.GregorianCalendar" />
    <c:out value="${now.timeInMillis}" />but now.year/Year/YEAR etc all give me 500 errors. I've also tried
    <jsp:useBean id="now" class="java.util.Date" />
    <c:out value="${now.year}" />But this just yields a constant. I know there is the SimpleDateFormat which I think would go with the java.util.Date example, but I'm not sure how it would be used in this context. Can anyone help me to get the date?

    Or how about using the JSTL tag for it:
    <jsp:useBean id="now" class="java.util.Date" />
    <fmt:formatDate value="${now}"/>This tag leverages the java.text.SimpleDateFormat to do its job.
    Cheers,
    evnafets

  • Problem with Out Reference in jsp

    Hi All
    Please Help Me
    My problem is
    <%
    ResultVo rvo=null;
    for(int i=0;i<alist.size();i++){
    rvo=(ResultVo)alist.get(i);
    %>
    <%=rvo.getData() %><%=rvo.getDel_tim() %>
    <%
    System.out.println("data"+rvo.getData()+""+i);
    System.out.println("dest"+rvo.getDest());
    } %>
    problem:
    1)here i am getting the first expression tag value
    in server it prints perfect (i mean all the values)
    but coming to jsp only the object first value printed on the jsp
    ex:
    alist.size() --10 objects
    and each object contains some values
    i repeated and try to print on the web using expression tag
    it prints only first object first value
    but i am in confusion what is the problem might be
    please help me
    thanking you

    u have to increment ur i
    add this to ur for:
    i++;

  • Problem displaying table generated by jsp

    Hi!
    I�m trying to build a dynamic form by calling different servlets from my jsp-page. Somthing goes wrong however, the first <select> generates another <select>, but when the second generates the third, the second <select>-table is overwritten. Why? Can�t I call request.getAttribute more than once?
    Please look at my code and help me understand why these strange things happens:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Egendefinierad s�kning</title>
    <link href="/taxen/myStyleSheet.css" rel="stylesheet" type="text/css">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    //-->
    </script>
    </head>
    <body>
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.util.*, taxen.*"%>
    <jsp:include page="header.html" flush="true" />
    <form name="EgenDefForm1">     
    <table width="250" align="center">
         <tr>
              <td width="110">�mneskategori</td>
         <td width="130">
              <select name="subject_category" onChange="MM_jumpMenu('parent',this,0)">
    <option value="choose">V&auml;lj</option>
    <option value="http://localhost:8080/servlet/taxen.SubjectCategoryHandler?subject_category=Marken">Marken
    </option>
    <option value="http://localhost:8080/servlet/taxen.SubjectCategoryHandler?subject_category=Skogens_alder">Skogens
    &aring;lder </option>
    <option value="http://localhost:8080/servlet/taxen.SubjectCategoryHandler?subject_category=Skogens_skador">Skogens
    skador </option>
    </select>
         </td>
    </tr>
    </table>
    <%
         String s_category = (String) request.getAttribute("SUBJECT_CATEGORY_RESULT");
    %>
    <%
         if ( s_category != null)
    {%>
    <table width="250" align="center">
         <tr>
              <td width="110">Underkategori</td>
         <td width="130">
                   <select name="sub_group" onChange="MM_jumpMenu('parent',this,0)">
              <option value="http://localhost:8080/servlet/taxen.SubGroupHandler?sub_group=<%=s_category%>">
                             <%     
                                  out.println(s_category);
                             %>
                        </option>
                        <option value="http://localhost:8080/servlet/taxen.SubGroupHandler?sub_group=<%=s_category%>">
                             <%     
                                  out.println(s_category);
                             %>
                        </option>
                   </select>
              </td>          
    </tr>
    </table>
    <%}%>
    <%
         String s_group = (String) request.getAttribute("SUB_CAT_RES");
    %>
    <%
         if ( s_group != null)
    {%>
    <table width="250" align="center">
         <tr>
              <td width="110">Variabel 1</td>
         <td width="130">
                   <select name="variable">
              <option value="<%=s_group%>">
                             <%     
                                  out.println(s_group);
                             %>
                        </option>
                   </select>
              </td>          
    </tr>
    </table>
    <%}%>
    </form>
    </body>
    </html>
    Regards!

    This may be your logic problem in the servlet.
    I am expecting that you are doing like this.
    On submitting the first select request....
    In the servlet you setting the request.setAttribute("SUBJECT_CATEGORY_RESULT", ......
    This is fine..
    when you are submitting the second select request.
    In the servlet you are setting the request.setAttribute("SUB_CAT_RES".... only.
    But here you should set the request.setAttribute("SUBJECT_CATEGORY_RESULT", ... ALSO
    Means both SUBJECT_CATEGORY_RESULT and SUB_CAT_RES should set in request.
    Then it will work fine..
    naveen

  • Featured Problem: Displaying unknown data in a GUI

    The featured problems are problems submitted for your enjoyment and education. In the world of java, there are many many things to learn. It is, naturally, impossible to know them all. If you are new or old to java, this will give your brain a workout. The goal isto come up with the BEST solution to the problem.
    Problem:
    You need to show some data in a GUI List control. The difficulty is that the objects of data and their type will not be known to you until runtime. What is the best way to accomplish this?

    You have a misunderstanding. You have NO CONTROL at all over the objects you are displaying. Reflection is the key, yes, but not on the object side. Instead on the cell renderer side.
    The solution calls for the invention of a ListCellRenderer that allows the user of the render to render on whatever he wants, field or method result. The user tells you what he wants to render on and you render on it. Furhtermore if he can change the target and have your rendere adapt on the fly, that would be better.

  • Problem displaying XML data in XSL page

    Hi There!
    I'm having trouble when adding XML data from the schema (which shows up  properly in the bindings panel)  to the XSL page..
    Following the step by step available here...
    http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822 510a94ae8d65-7a56a.html#ionCTAAnchor
    After  adding the XML item to the XSL file it ends up showing  up as  parent/client/name   (no brackets)  Instead of like the  example above  where it should display as {parent/client/name} and be  highlighted.    Also when previewing the XSL document it just shows   'parent/client/name'  instead of the actuall XML content..
    I  believe the XML data source is properly attached because it shows up in  the bindings panel..  But I don't know what else could be going wrong..
    Any help would be great!

    This is being enhanced to that the [...] button that appears in the data grid is available for all grid of data so that a popup with an extended area is shown.
    -kris

  • Problem in displaying extension data at item level in JSP!!!

    Hi Experts,
    I am facing a problem when i try to display extension data in JSP. This is how i have coded in CRM system and in JSP:
    After searching an order in the webshop let say order no 1, and i ll select this order no .1. Now the BADI CRM_ISA_BASKET_ITEMS is triggered and in the method getitems_getdata, i have written a code with hard coded values like this:
    method IF_EX_CRM_ISA_BASKET_ITEMS~GETITEMS_GET_DATA..
    data:wa_extension like line of ct_extension.
    wa_extension-ref_guid = '498AB6EC7B623152E1000000AC1383C5'.(ref guid is item guid of the order 1)
    wa_extension-name = 'Z_CustomItemExtData'.
    wa_extension-value = 'he is a good boy'(hardcoded value) .
    append wa_extension to ct_extension.
    endmethod.
    And in JSP i have written code like this to display:
    <%--  code for extension data --%>                       
    <tr>
    <td class="identifier">Ext data</td>
    <td class="value" ><%= JspUtil.encodeHtml(orderitem.getExtensionData("Z_CustomItemExtData")) %></td>
    </tr>
    But i am not getting the value in the JSP which i have hard coded in the BADI method. Is there any thing wrong in the above code? Please help me in this as i am very much new to ABAP.
    Thanks a lot in Advance!!
    Regards,
    lakshman.

    hi,
    did you hardcode the ref-guid too? This could be the problem.
    Regards
    Michael

  • Problem Displaying data from oracle in JTable

    Please can any one help me? I have a problem displaying the data fetched from oracle database(ResultSet) in JTables. Can any one provide me with any possible way out(and any alternative).

    User,
    As suggested in the other post - Google/Books/find a mentor is the best option.

  • How to display the data in XML files into JSP using Jdeveloper.

    Hi All,
    I have two XML files one XML file has the view names and the other has the table names of a particular views, how to display the data in JSP using JDeveloper where when i click a particular view the list of tables of that particular view from XML file two should be displayed in JSP Page.
    Are there any reference documents, regarding the above process please can anyone guide through how to do it.

    Let the servlet ask your business tier to provide the data, then stuff it into beans, and pack those into the Session instance. Then forward the request to the JSP, let the JSP get those beans and display them.

  • DataGrid does not display XML data

    Hello, and thanks for reading this...
    I am having a problem displaying XMLList data in a DataGrid.
    The data is coming from a Tree control, which is receiving it
    from a database using HTTPService.
    The data is a list of "Job Orders" from a MySQL database,
    being formatted as XML by a PHP page.
    If it would be helpful to see the actual XML, a sample is
    here:
    http://www.anaheimwib.com/_login/get_all_orders_test2.php
    All is going well until I get to the DataGrid, which doesn't
    display the data, although I know it is there as I can see it in
    debug mode. I've checked the dataField property of the appropriate
    DataGrid column, and it appears correct.
    Following is a summary of the relevant code.
    ...An HTTPService named "get_all_job_orders" retrieves
    records from a MySQL database via PHP...
    ...Results are formatted as E4X:
    HTTPService resultFormat="e4x"
    ...An XMLListCollection's source property is set to the
    returned E4X XML results:
    ...The "order" node is what is being used as the top-level of
    the XML data.
    <mx:XMLListCollection id="jobOrdersReviewXMLList"
    source="{get_all_job_orders.lastResult.order}"/>
    ...The "jobOrdersReviewXMLList" collection is assigned to be
    the dataProvider property of a Tree list, using the @name syntax to
    display the nodes correctly, and a change event function is defined
    to add the records to a DataGrid on a separate Component for
    viewing the XML records:
    <mx:Tree dataProvider="{jobOrdersReviewXMLList}"
    labelField="@name"
    change="jobPosForm.addTreePositionsToDG(event)"/>
    ...Here is the relevant "jobPosForm" code (the Job Positions
    Form, a separate Component based on a Form) :
    ...A variable is declared:
    [Bindable]
    public var positionsArray:XMLList;
    ...The variable is initialized on CreationComplete event of
    the Form:
    positionsArray = new XMLList;
    ...The Tree's change event function is defined within the
    "jobPosForm" Component.
    ...Clicking on a Tree node fires the Change event.
    ...This passes an event object to the function.
    ...This event object contains the XML from the selected Tree
    node.
    ...The Tree node's XML data is passed into the positionsArray
    XMLList.
    ...This array is the dataProvider for the DataGrid, as you
    will see in the following block.
    public function addTreePositionsToDG(event:Event):void{
    this.positionsArray = selectedNode.positions.position;
    ...A datagrid has its dataProvider is bound to
    positionsArray.
    ...(I will only show one column defined here for brevity.)
    ...This column has its dataField property set to "POS_TITLE",
    a field in the returned XML record:
    <mx:DataGrid width="100%" variableRowHeight="true"
    height="75%" id="dgPositions"
    dataProvider="{positionsArray}" editable="false">
    <mx:columns>
    <mx:DataGridColumn width="25" headerText="Position Title"
    dataField="POS_TITLE"/>
    </mx:columns>
    </mx:DataGrid>
    In debug mode, I can examine the datagrid's dataProvider
    property, and see that the correct XML data from the Tree control
    is present. However, The datagrid does not display the data in any
    of its 6 columns.
    Does anyone have any advice?
    Thanks for your time.

    Hello again,
    I came up with a method of populating the DataGrid from the
    selected Item of a Tree Control which displays complex XML data and
    XML attributes. After the user clicks on a Tree branch, I call this
    function:
    public function addTreePositionsToDG(event:Event):void{
    //Retrieve all "position" nodes from tree.
    //Loop thru each Position.
    //Add Position data to the positionsArray Array Collection.
    //The DataGrid dataprovider is bound to this array, and will
    be updated.
    positionsArray = new ArrayCollection();
    var selectedNode:Object=event.target.selectedItem;//Contains
    entire branch.
    for each (var position:XML in
    selectedNode.positions.position){
    var posArray:Array = new Array();
    posArray.PK_POSITIONID = position.@PK_POSITIONID;
    posArray.FK_ORDERID = position.@FK_ORDERID;
    posArray.POS_TITLE = position.@POS_TITLE;
    posArray.NUM_YOUTH = position.@NUM_YOUTH;
    posArray.AGE_1617 = position.@AGE_1617;
    posArray.AGE_1821 = position.@AGE_1821;
    posArray.HOURS_WK = position.@HOURS_WK;
    posArray.WAGE_RANGE_FROM = position.@WAGE_RANGE_FROM;
    posArray.WAGE_RANGE_TO = position.@WAGE_RANGE_TO;
    posArray.JOB_DESCR = position.@JOB_DESCR;
    posArray.DES_SKILLS = position.@DES_SKILLS;
    positionsArray.addItem(posArray);
    So, I just had to manually go through the selected Tree node,
    copy each XML attribute into a simple Array, then ADD this Array to
    an ArrayCollection being used as the DataProvider for the DataGrid.
    It's not elegant, but it works and I don't have to use a Label
    Function, which was getting way too complicated. I still think that
    Flex should have an easier way of doing this. There probably is an
    easier way, but the Flex documentation doesn't provide an easy path
    to it.
    I want to thank you, Tracy, for the all the help. I checked
    out the examples you have at www.cflex.net and they are very
    helpful. I bookmarked the site and will be using it as a resource
    from now on.

  • Dynaminc display of date

    Hi guys,
           I got a problem displaying the data in the selection screen..I got a radiobutton i need to give some discription for the radiobutton such that it should display the previous days date dynamically...
    eg: * activity for "15/05/2005"..
       So the date should be dynamic it should show the previous days date.
    Hope u understood my problem.....Pls help me out ASAP.......

    Hi,
    Try this:
    SELECTION-SCREEN COMMENT /1(50) comm1 MODIF ID mg1.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN COMMENT /1(30) comm2.
    SELECTION-SCREEN ULINE /1(50).
    selection-screen begin of line.
    SELECTION-SCREEN COMMENT 1(30) comm3.
    PARAMETERS: r1 RADIOBUTTON GROUP rad1.
    selection-screen end of line.
    parameters: r2 RADIOBUTTON GROUP rad1,
                r3 RADIOBUTTON GROUP rad1.
    SELECTION-SCREEN ULINE /1(50).
    AT SELECTION-SCREEN OUTPUT.
      comm1 ='Selection Screen'.
      comm2 ='Select one'.
      comm3 = sy-datum.
      LOOP AT SCREEN.
        IF screen-group1 = 'MG1'.
           screen-intensified = '1'.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    I've found the example in the Online Help and added the line with the date.
    HTH
    Stefan

  • Jstl tags to display System date.

    Hi there,
    Please let me know how to how to display system date on jsp page using jstl.
    I dont know much about jstl, and i was till now using java code in jsp instead of jstl.
    Since using java in jsp is considered a bad programing these days, I dont want to use java
    to display the date.
    Can anyone help me switch to jstl tags.
    Please help me with the date issue.

    [This will help you|http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/index.html] learn what JSTL tags are available. Once you get that it should be relatively easy to figure out what you nee. If you have questions on a particular tag then a [Google search almost always|http://www.google.com/search?q=jstl+fmt%3AformatDate] brings up example usage.

  • Problem displaying data in Excel with Jsp

    HI,
    For some reason when i save data from jsp to excel, my Excel dont display data.This code was working fine from past 3 years all of sudden it starts givin this problem.
    However When i open my .xls file in notepad i see data there. The problem is because of XML declaration (<?xml version="1.0" encoding="UTF-8"?> which parsed generate. If i remove this it works fine.
    Out put in file looks like this
    <?xml version="1.0" encoding="UTF-8"?>
    <table border=1 width="100%">
    <tr>
    <TH>Name</TH>
    <TH>Last Name</TH>
    <TH>state</TH>
    <TH>Country</TH>
    <TH>Currency</TH>
    </tr>
    <tr>
    <TD class="odd">John</TD>
    <TD class="odd">Hayden</TD>
    <TD class="odd">IL</TD>
    <TD class="odd">USA</TD>
    <TD class="odd">USD</TD>
    </tr>
    <tr>
    <tr>
    <TD class="odd">Ricky</TD>
    <TD class="odd">Ponting</TD>
    <TD class="odd">IL</TD>
    <TD class="odd">USA</TD>
    <TD class="odd">EUR</TD>
    </tr>
    </tr>
    </table>
    Jsp Code
    String rptHTML = (String)session.getAttribute("ReportStrHTML");
         System.out.println(rptHTML);
         response.setHeader("Content-Disposition","attachment;filename=Test.xls");
         response.setContentType("application/vnd.ms-excel");
    Thanks

    In Excel, Tools > Macro > security > medicum and Trusted tab check To access VB.

Maybe you are looking for

  • Bdc for multiple line items

    hi all, i am developing bdc program to upload multiple line items for ml10. i am uploading folling fields spec_no astyp txz01, sort1, waers, matkl, ekorg, srvpos ' service number menge. 'quantity service number and quantity are multiple line items. i

  • Moving folder from Spotlight to desktop

    I just recently got a new Mac Pro to replace a defective one (yes, it happens). I didn't want to transfer all of my files from the old machine in case there was a corrupt file somewhere. Now I am looking for some of my Microsoft Word documents. A fol

  • "[item name]" can't be modified or deleted because it's required by OS X.

    OK, so I purchase ID3 Editor. • Download a .dmg file. • Open disk image: • Instructions tell me to copy software to Applications folder. Which I do. • Want to rename the Extras folder so that it reads "ID3 Extras", and shows up next to the App it ref

  • Need help with this problem.

    I have just updated my ipod and it is saying i need to connect it to my Apple iPod Power Adapter, the problem is that i do not have one. Is there anyway to reset the update process untill i get a adapter. I have tried resetting it with the instructio

  • I have the iphone 5 and when I try and get new apps it says an unknown error has occurred.  The password is correct

    I have the iphone 5 and when i try and get new apps it says an unknown error has occured.  The password is correct.  A couple of times i have seen a little glitch in small lines of pixels across the screen.  Started happening about the same time.....