Problem in showing value of a string object of jsp to on page

hello there
i have a problem that i m fatching a value from a JavaBean in my jsp page now i want to print that value in my jsp page but i is createing problem
my probelm is that the value which i have been fatching from my javabean contain code like
#include<stdio.h>
#include<conio.h>
void main
int a=10;
printf("%d",a);
getch();
i m getting this code in a variable in a String object myCode
and when i m displaying this using
<%=myCode%>
it is giving output as follows
#include<stdio.h> #include<conio.h> void main { int a=10; printf("%d",a);
getch();}
can you tell me why it is creating a problem
plz help me
thanks in advance
pawan gupta

HTML formats in its own special way. It ignores spaces/newlines.
Try using <pre> tags to tell the browser "this is pre-formatted text. Don't screw around with it"
ie
<pre><%= myCode %></pre>
Cheers,
evnafets

Similar Messages

  • Problems showing Values in a DROPDOWNBYINDEX

    Hello together,
    I've got a problem of showing values in a Drop Down  Box.
    I've got 1 Dropdown box, 1 button and a text field. In the text field i'm wirting a carrid for example AC.
    If i press the button in the Drop down box should show the name to the corresponding carrid for example Air Canada.
    this is my code till yet. But i don't see what's missing.
    Maybe anybody can help?
      Data: context_node type ref to if_wd_context_node.
      Data: it_carriers TYPE STANDARD TABLE OF scarr,
            wa_carriers LIKE LINE OF it_carriers,
            wa_carrid(3) TYPE c.
      context_node = wd_context->get_child_node( 'DROPDOWN_CARRIERS' ).
      context_node->get_attribute( exporting Name = 'CARRID' importing value = wa_carrid ).
      select * from scarr
        INTO wa_carriers
        WHERE carrid = wa_carrid.
        APPEND wa_carriers TO it_carriers.
      ENDSELECT.
      context_node = wd_context->get_child_node( name = 'CARRID').
      context_node->BIND_TABLE( new_items = it_carriers ).

    Get the selected row by using code wizard and use the values of the structure whereever you want. Refer to the below code:
    Suppose I have a Node NODE_OUTPUT and binded with my table UI element. We need to get the selected row (ls_node_output) in my Button UI event handler method as below:
        DATA lo_nd_node_output TYPE REF TO if_wd_context_node.
        DATA lo_el_node_output TYPE REF TO if_wd_context_element.
        DATA ls_node_output TYPE wd_this->element_node_output.
      navigate from <CONTEXT> to <NODE_OUTPUT> via lead selection
        lo_nd_node_output = wd_context->get_child_node( name = wd_this->wdctx_node_output ).
      get element via lead selection
        lo_el_node_output = lo_nd_node_output->get_element( ).
      get all declared attributes
        lo_el_node_output->get_static_attributes(
          IMPORTING
            static_attributes = ls_node_output ).

  • 2D stacked column does not show values

    Hi Friends,
    I am new to Apex. I have a 2D column chart with two columns for every data point. The display value check box is checked and I can see the values on the chart. But now when i to make it a stacked 2 D column, the Show Values checkbox field gets disabled and the values does not appear on the stacked 2D column chart. I tried the same with 3S stacked column chart and even there the show values gets disabled.
    Is there any way i can display the values on the chart for a stacked column? I can see the values when i hover on it in case of Stacked column chart but I need to display the values on the chart.
    Kindly let me know how i can do this in Apex?

    Hi Pradeep,
    In earlier releases of Application Express, the supported version of AnyChart Flash charts did not fully support the display of values for Stacked charts. Therefore, the "Show Values" checkbox would be disabled on the Chart Attributes page. Since our 4.0 release, with the integration of AnyChart 5 charts, the option to display values on stacked charts is exposed via the Chart Attributes page. To take advantage of this option, along with many other charting improvements introduced with our 4.0 release, I would recommend that you upgrade to the latest version of Application Express.
    Alternatively, you could switch your existing chart to use custom XML, and change the following line of code in the chart XML from:
    <names show="no"/> to <names show="yes"/>For further information on customising your chart XML, please refer to the AnyChart 3 documentation: http://3.anychart.com/products/docs/anychart/index.htm.
    Regards,
    Hilary

  • Problem in getting last value of a string in Function Module

    Hi,
    I am working on FM in which i have to put highfen mark which is working ok,but the problem if there is when the value of string finds a space it should not insert highfen in it and i am not able to put the condition in it as it showing the higfen even when the word is full in the first line.i want to show highfen where the word is not able to display complete. here is d code which i am using right now. plzz provide me guidlines to solve this problem.
    here's d code:-
    FUNCTION Z_STRING_LENGTH1.
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(I_STRING) TYPE  STRING
    *"     VALUE(LENGTH) TYPE  I
    *"  EXPORTING
    *"     VALUE(E_STRING) TYPE  STRING
    data: STRING_F type string, "Stores the value in string format
          STRING_LENGTH type i, "Length of the string
          DIFF type i,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 type string,  "Stores the 1st String
          STRING2 type string,  "Stores the 2nd String
          STRING3 type string,  "Stores the 3rd String
          STRING4 type string,  "Stores the 3rd String
          STRING5 type string,  "Stores the 3rd String
          LENGTH2 type I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING2 = STRING_F+LENGTH(DIFF).
    ELSE.
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    length2 = length - 1.
    STRING3 = STRING1+length2(1).
    STRING4 = STRING2+0(1).
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      concatenate STRING1 '-' STRING2  into STRING5.
      e_string = STRING5.
    ELSE.
      concatenate  STRING1 STRING2 into STRING5.
      e_string = STRING5.
    ENDIF.
    ENDFUNCTION.
    Edited by: ricx .s on May 12, 2009 5:20 AM

    Hi,
    I checked your code... its working fine except for some cases it is giving dumps for which I have added certain if conditions....
    Please check the modified code below... have optimized it as well by removing one extra if condition....
    you can copy and paste the code below...
    DATA: STRING_F TYPE STRING, "Stores the value in string format
          STRING_LENGTH TYPE I, "Length of the string
          DIFF TYPE I,          "Difference among the value
          DIFF1 TYPE C,
          STRING1 TYPE STRING,  "Stores the 1st String
          STRING2 TYPE STRING,  "Stores the 2nd String
          STRING3 TYPE STRING,  "Stores the 3rd String
          STRING4 TYPE STRING,  "Stores the 3rd String
          STRING5 TYPE STRING,  "Stores the 3rd String
          LENGTH2 TYPE I.
    STRING_F = I_STRING.
    STRING_LENGTH = STRLEN( I_STRING ).
    DIFF = STRING_LENGTH - LENGTH.
    IF DIFF LE 0.
      DIFF = 0.
    ENDIF.
    IF LENGTH LE STRING_LENGTH.
      STRING1 = STRING_F(LENGTH).
      STRING2 = STRING_F+LENGTH(DIFF). " added this statement in this if itself instead of one extra if
    " which is not required
    ELSE.
      STRING1 = STRING_F(STRING_LENGTH).
      STRING2 = STRING_F+STRING_LENGTH(DIFF).
    ENDIF.
    IF LENGTH IS NOT INITIAL.
      LENGTH2 = LENGTH - 1.
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value as 0
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 0, then it gives me a dump
    STRING3 = STRING1+LENGTH2(1).
    IF STRING2 IS NOT INITIAL.
      STRING4 = STRING2+0(1).
    ENDIF.
    " put this if condition as there is a dump occuring at this place.
    " Dump occurs when you give the length value greater than or equal to
    " the string length
    " Say for example the value of I_STRING, I passed it as SIDDARTH
    " and the length I passed as 8, then it gives me a dump
    IF LENGTH LE STRING_LENGTH AND STRING3 NE SPACE AND STRING4 NE SPACE.
      CONCATENATE STRING1 '-' STRING2  INTO STRING5.
      E_STRING = STRING5.
    ELSE.
      CONCATENATE  STRING1 STRING2 INTO STRING5.
      E_STRING = STRING5.
    ENDIF.

  • Is there a way of calling out all values in a String to name an object?

    Is the above possible?
    As in the generic statement below,
    [class name] [objectname] = new [constructor];
    to be able to make the value of a String to be the objectname? such that if this instance
    String s = "Peter";
    Then the objectname will be Peter, as in
    [class name] [Peter] = new [constructor];

    you could do something like this:
    String str[] = new String[10];
    then you could get the value of a string from a user and place it in a String variable.
    TextField text1 = new TextField ();
    String nameofObject = text1.getText();
    now you can do something like:
    create a button to submit the new name and then check to see if the button was pressed. If the button was pressed, iterate through the loop and set the str array object equal to the value of nameofObject string. Do it something like:
    str[0] = nameofObject;
    now you should be able to refer to the newly created object as the string name entered into the TextField you retrieved.
    That is just off the top of my head. I am sure what you are trying to do can be done.
    Hope that helps,
    Kent

  • Unable to read big files into string object & java.lang.OutOfMemory Problem

    Hi All,
    I have an application that uses applet and servlet communication. On the client side I am reading an large xml file of 12MB size (using JFileChooser) and converting the file to an string object using below code. But I am getting java.lang.OutOfMemory on the client side . But the same below code works fine for small xml files which are less than 4MB sizes:
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF8"), 1024*12);
    String s, s2 = new String();
    while((s = in.readLine())!= null)
    s2 += s + "\n";
    I even tried the below code but still java.lang.OutOfMemory is coming:
    while (true)
    int i = in.read();
    if (i == -1)
    break;
    sb.append(i);
    Please let me know what am I doing wrong here ...

    Hi,
    I could avoid the java.lang.OutOfMemory error using below code. But using below code I could read small files of sizes less than 4MB
    but with large files of 12 MB the below code just simply hangs and I am unable to print the string object namely 's'.
    My purpose is to construct an String or StringBuffer object out the user uploaded xml file at the client side and pass that object to server for processing. So how can I construct such object avoid memory problem and increasing the performance of such operations.
    BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
    byte[] b = new byte[in.available()];
    in.read(b, 0, b.length);
    String s = new String(b, 0, b.length);
    in.close();
    Thanks & Regards,
    Sony.

  • Getting char values from a string problem

    Hi,
    Here's an example of what I'm trying to do:
    boolean loopSwitch = true;
    while (loopSwitch)
         String orderDecider = JOptionPane.showInputDialog (null, "Would you like your numbers to be ordered in   ascending or descending order(A/D)",      "Order decision", JOptionPane.QUESTION_MESSAGE);
         if (orderDecider == A)
         loopSwitch = false;
         }I basically want the user to input either a/A/d/D and to get the char values from the string so I can use them in an if statement.
    Basically, I wanna parse the string into a char.
    Is this possible?
    Thanks.
    Edited by: xcd on Oct 16, 2009 8:38 AM

    Why not just use the String.equals() method to compare a String to a String?
    But if you must, you can use the String.charAt() method to return a char at a particular location in the String.
    Note: char literals need to be surrounded by single quotes ('A') and String literals need to be surrounded by double quotes ("A").

  • Implicit coercion of a value of type String to an unError while Adding Dynamic Rows To Flex DataGrid

    Hi friends
    I  want to add interger for in next next rows while clicking tab  button,one i enter all the values in one row if i press tab means next  row will be editable.for making that i added the following code.i have  some error shows like this
        [Bindable]
                    private var tasks:ArrayCollection;
                    private static const ADD_TASK:int= "";
                    private function init():void
                        tasks = new ArrayCollection();
                        tasks.addItem(new Task(0.01,100000,0));
                        tasks.addItem({frmAmount:ADD_TASK});
                    private function checkEdit(e:DataGridEvent):void
                        // Do not allow editing of Add Task row except for
                        // "Click to Add" column
                        if(e.rowIndex == tasks.length - 1 && e.columnIndex != 0)
                            e.preventDefault();
            private function editEnd(e:DataGridEvent):void
                    // Adding a new task
                    if(e.rowIndex == tasks.length - 1)
                    var txtIn:TextInput =TextInput(e.currentTarget.itemEditorInstance);
                    var dt:Object = e.itemRenderer.data;
                    // Add new task
                    if(parseInt(txtIn.text) != ADD_TASK)
                        tasks.addItemAt(new Task(parseInt(txtIn.text), 0, ""), e.rowIndex);----->Multiple markers at this line:
                                                                                                                             -1067: Implicit coercion of a value of type String to an unrelated type int.
                                                                                                                                -txtIn
                    // Destroy item editor
                    commPlanDetGrid.destroyItemEditor();
                        // Stop default behavior
                    e.preventDefault();
            ]]>
    Please help if any suggession
    Thanks in advance
    B.Venkatesan

    The error message indicates the problem fairly clearly.  _feed_list is defined as a ComboBox in your first line of code.  You are passing that as an argument in your populate(_feed_list) line of code.  However, the populate function is expecting an XMLList object to be passed, not a ComboBox.
    You probably really mean to be using...
              populate(feed_items);
    since that is the only XMLList to be found

  • Converting Base64 encoded String to String object

    Hi,
    Description:
    I have a Base64 encoded string and I am using this API for it,
    [ http://ws.apache.org/axis/java/apiDocs/org/apache/axis/encoding/Base64.html]
    I am simply trying to convert it to a String object.
    Problem:
    When I try and write the String, ( which is xml ) as a XMLType to a oracle 9i database I am getting a "Cannot map Unicode to Oracle character." The root problem is because of the conversion of the base64 encoded string to a String object. I noticed that some weird square characters show up at the start of the string after i convert it. It seems like I am not properly converting to a String object. If i change the value of the variable on the fly and delete these little characters at the start, I don't get the uni code error. Just looking for a second thought on this.
    Code: Converting Base64 Encoded String to String object
    public String decodeToString( String base64String )
        byte[] decodedByteArray = Base64.decode( base64String );
        String decodedString = new String( decodedByteArray, "UTF-8");
    }Any suggestions?

    To answer bigdaddy's question and clairfy a bit more:
    Constraints:
    1. Using a integrated 3rd party software that expects a Base64 encoded String and sends back a encoded base64 String.
    2. Using JSF
    3. Oracle 10g database and storing in a XMLType column.
    Steps in process.
    1. I submit my base64 encoded String to this 3rd party software.
    2. The tool takes the encoded string and renders a output that works correctly. The XML can be modified dynamically using this tool.
    3. I have a button that is binded to my jsf backing bean. When that button is clicked, the 3rd party tool sets a backing bean string value with the Base64 String representing the updated XML.
    4. On the backend in my jsf backing bean, i attempt to decode it to string value to store in the oracle database as a XML type. Upon converting the byte[] array to a String, i get this conversion issue.
    Possibly what is happen is that the tool is sending me a different encoding that is not UTF-8. I thought maybe there was a better way of doing the decoding that i wasn't looking at. I will proceed down that path and look at the possibility that the tool is sending back a different encoding then what it should. I was just looking for input on doing the byte[] decoding.
    Thanks for the input though.
    Edited by: haju on Apr 9, 2009 8:41 AM

  • Using Convert to handle NULL values for empty Strings ""

    After having had the problem with null values not being returned as nulls and reading some suggestion solution I added a converter to my application.
      <converter>
        <converter-id>NullStringConverter</converter-id>
        <converter-for-class>java.lang.String</converter-for-class>
        <converter-class>com.j2anywhere.addressbookserver.web.NullStringConverter</converter-class>
      </converter>
    ...I then implemented it as follows:
      public String getAsString(FacesContext context, UIComponent component, Object object)
        System.out.println("Converting to String : "+object);
        if (object == null)
          System.out.println("READING null");
          return "NULL";
        else
          if (((String)object).equals(""))
            System.out.println("READING null (Second Check)");
            return null;       
          else
            return object.toString();
      public Object getAsObject(FacesContext context, UIComponent component, String value)
        System.out.println("Converting to Object: "+value+"-"+value.trim().length());
        if (value.trim().length()==0 || value.equals("NULL"))
          System.out.println("WRITING null");
          return null;
        else
          return value.toUpperCase();
    ...I can see that it is converting my values, however the object to which the inputText fields are bound are still set to empty strings ""
    <h:inputText size="50" value="#{addressBookController.contactDetails.information}" converter="NullStringConverter"/>Also when reading the object values any nulls are already converted to empty strings before ariving at the converter. It seems that there is a default converter handling string values.
    How can I resolve this problem as set nulls when the input value is an empty string other then checking every string in my class individually. I would really hate to pollute my object model with empty string tests.
    Thanks in advance
    Edited by: j2anywhere.com on Oct 19, 2008 9:06 AM

    I changed my converter as suggested :
      public Object getAsObject(FacesContext context, UIComponent component, String value)
        if (value == null || value.trim().length() == 0)
          if (component instanceof EditableValueHolder)
            System.out.println("SUBMITTED VALUE SET TO NULL");
            ((EditableValueHolder) component).setSubmittedValue(null);
          else
            System.out.println("COMPONENT :"+component.getClass().getName());
          System.out.println("Converting to Object: " + value + "< to " + null);
          return null;
        System.out.println("Converting to Object: " + value + "< to " + value);
        return value;
      }which produces the following output :
    SUBMITTED VALUE SET TO NULL
    Converting to Object: < to null
    Info : The INFO line however comes from my controller object where I print out the set value :
    package com.simple;
    import java.util.ArrayList;
    import java.util.List;
    public class Controller
      private String information;
      /** Creates a new instance of Controller */
      public Controller()
        System.out.println("Createing Controller");
        information = "Constructed";
      public String process()
        System.out.println("Info : "+getInformation());
        return "processed";
      public String reset()
        setInformation("Re-Constructed");
        System.out.println("Info : "+getInformation());
        return "processed";
      public String setNull()
        setInformation(null);
        System.out.println("Info : "+getInformation());
        return "processed";
      public String getInformation()
        return information;
      public void setInformation(String information)
        this.information = information;
    }I also changes my JSP / JSF page a little. Here is the updated version
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%--
        This file is an entry point for JavaServer Faces application.
    --%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
      </head>
      <body>
        <f:view>
          <h:form>
            <h:inputText id="value" value="#{Controller.information}"/>
            <hr/>
            <h:commandLink action="#{Controller.process}">
              <h:outputText id="clicker" value="Process"/>
            </h:commandLink>             
            <hr/>
            <h:commandLink action="#{Controller.reset}">
              <h:outputText id="reset" value="Reset"/>
            </h:commandLink>             
            <hr/>
            <h:commandLink action="#{Controller.setNull}">
              <h:outputText id="setNull" value="Set Null"/>
            </h:commandLink>             
          </h:form>
        </f:view>
      </body>
    </html>The converter is declared for the String class in the faces configuration file. From the log message is appears to be invoked, however the object is not set to null.
    I tested this with JSF 1.2_04-b20-p03 as well as 1.2_09-b02-FCS.
    any other suggestions what could be causing this.

  • Probleme changing the value of a variable in movieclip from my scene

    Hello,
    i have a probleme changing the value of a variable in movieclip from my scene. i explain: I have combobox on my scene containing categories, and in the scene i load an xml file containing links to php files that work with the combobox.
    Also on the scene i have a movieclip "filmstrip", inside this movieclip on the first frame i have a script loading the php file selected in the scene . i use a load() function with a variable "theUrl" inside like this : T.load(theUrl);.
    In my scene i want to change the value of "theUrl" inside the movieClip filmstrip. I tried filmstrip.theUrl = url; But it doesnt work
    the xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <slideshow>
    <area title1="10 Last updated" link1="link1.php"/>
    <area title1="special" link1="link2.php"/>
    </slideshow>
    here is the code on my scene:
    var link1:Array = new Array();
    var LINK:String;
    var url:String;
    var whoOn:Number;
    whoOn=0;
    var x:XML = new XML();
    x.ignoreWhite = true;
    x.onLoad = function(success) {
    var photos:Array = this.firstChild.childNodes;
    for (i=0; i<photos.length; i++) {
    _root.link1.push(photos[i].attributes.link1);
    url=link1[whoOn];
    filmstrip.theUrl=url;//<<--HERE
    x.load("category.xml");
    var cbListener:Object = new Object();
    cbListener.change = function(event_obj:Object) {
    trace(select.selectedItem.label);
    if (select.selectedItem.label == "Last updated") {
    whoOn=0;
    } else if (select.selectedItem.label == "Special") {
    whoOn=1;
    url=link1[whoOn];
    filmstrip.theUrl=url; //<<-----HERE  
    select.addEventListener("change",cbListener);
    here is the code inside the movie clip "filmstrip"
    var T:XML = new XML();
    T.ignoreWhite = true;
    T.onLoad = function(xml) {
    etc etc etc }
    T.load(theUrl);    //<<---HERE it still undefined

    YESSSS . Thanks you very much Kglad it wotk i put all in a function inside the filmstrip function Tload(theUrl){etc ect}and in the root i call it like this filmstrip.Tload(theUrl);   and it works
    code in the root var link1:Array = new Array();
    var LINK:String;
    var url:String;
    var whoOn:Number;
    whoOn=0;
    var x:XML = new XML();
    x.ignoreWhite = true;
    x.onLoad = function(success) {
    var photos:Array = this.firstChild.childNodes;
    for (i=0; i<photos.length; i++) {
    _root.link1.push(photos[i].attributes.link1);
    url=link1[whoOn];
    theUrl=url;
    filmstrip.Tload(theUrl);//<<--HERE
    x.load("category.xml");
    var cbListener:Object = new Object();
    cbListener.change = function(event_obj:Object) {
    trace(select.selectedItem.label);
    if (select.selectedItem.label == "Last updated") {
    whoOn=0;
    } else if (select.selectedItem.label == "Special") {
    whoOn=1;
    url=link1[whoOn];
    theUrl=url;
    filmstrip.Tload(theUrl);//<<-----HERE
    select.addEventListener("change",cbListener);

  • Flash Builder 4.6 code hinter problem - not showing some methods

    Hi All,
    I have a problem with FB code hinter. It does not show some methods on an object.
    To be exact I created a Date object and FB code hinter does not show .toDateString method (actually I it shows only one to string method - .ToString(), although according to docs there are more)
    When I use .toDateString method, code still compiles and work just fine, however method is not showing up in code hinter, which is really annoying..
    Anyone had this problem? If so, please, share some wisdom how to solve this thing.
    Thanks in advance.
    UPDATE:
    Here is some more info in my problem.
    I have tried to reinstall the application, but it did not help.
    So what I did was:
    * first I installed FB standard edition version 4.
    * I checked the code hinter and it worked. It showed .toDateString method.
    * I have purchased FB standard 4.5 upgrade.
    * I installed this upgrade, and boom the code hinter does not show the method...
    * Next I tried to create a project with Flex 4.1 sdk and then it worked - method was there. So the problem is with 4.6 sdk apparently...sucks...

    Hi, I have the same problem. I have a new FB 4.6 installation and it is my first FB installation. Do you have a solution already?

  • Why should I wrap String objects in a class for my HtmlDataTable?

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • String object vs String literal

    Hi ,
    I understand how the string objects are created using new operator and using literal.I also understand how they are stored in memory.All I want to know is that when and why should I create a String object using new and when I should create an object using literal.Is there any specific reason for creating an object using new operator when objects created by both the ways are immutable.
    Thanks for the help in advance.
    Thanks
    Mouli

    If you look at the String source code (particularly the constructors) youll learn a lot.
    String objects contain a char[] array - and this is the most important part --> a start and length value.
    I believe they were attempting to optimize, but this has important implications for developers.
    String objects dont necessarily store just the text you see, it may just reference a much bigger char array.
    For example, say an API passes you a string that is (lets pretend) a file path (C:\files\java\...\file.txt) that is 1,000,000 characters long.
    Now say that you call getFileName() and want to save the filename in a list.
    String filename = API.getFile("...").getFileName();
    List.add(filename);
    Say you do this about 250,000 times.
    You estimate that the average file name is 10 chars and ensure there is that much RAM.
    You run out of memory. Why?
    Well, this example actually happened to me in a real program I was writing to archive drive files.
    File.getFilename() returns a substring() of the entire File path.
    However, substring is implemented to return a String that just references the original char[] array!
    So the really long file path never gets garbage collected!
    I was able to fix the program by coding it:
    String filename = new String(API.getFile("...").getFileName()); // Copies only the needed chars!
    List.add(filename);
    So thats really all you need to watch out for. If memory is a concern in your program you want to
    make sure you arent referencing large char[] arrays unnecessarily.
    But like all things, this is rarely anything to give much thought to.
    Only something to remember if you run into problems after coding sensibly and profiling
    (or in my case, crashing with OOM exceptions, lol).

Maybe you are looking for

  • Generation of Spool Request in F110 automatic payment progrm transaction

    Hi All, I am facing a problem of spool request for t-code F110. for other transactions like F-58 and FBZ5 the spool request is getting generated. but not for F110 t code. I am creating a variant for each bank that I am using in F110. Seperate cheque

  • Who can use Web Service Forms??

    Just wondering, where do I find the specs for who can submit my Web Service forms. So far Reader 7 and Acrobat Standard 6 cannot use my Designer 7 web service forms (even after saving as Acrobat6 compatible static forms) My forms are not dynamic, the

  • Color picker not availble in pc version

    Hi- I have Freehand installed on three machines: 2 pc's and a Mac. On my Mac, the color picker works beautifully. But on my pc's, whenever I select the color wheel icon, I am brought to the standard box containing cubes of about 30 basic colors or so

  • Why doesn't my iPad screen rotate all of a sudden

    I have been using my IPad 2 for a few months now and as of yesterday it won't rotate ...what gives...and for a day or so it wouldn't send emails as a reply...didn't go into drafts either...just disappeared...weird or something I am doing ?  could it

  • Wavefrom comparing

    Hi,  my application is to check the PCB i/o pins... first i have to corresponding signal to every pin in GOOD PCB board and the output of each pin should saved in excel with the help of write to spreadsheet.. then the database be act as master for ot