How to assign bean value to a local variable in JSP using struts.

Hi everybody!
I've a problem that puzzled me on how to assign a bean value to a local variable like String in JSP using struts.
we can have someting like this to display the value
<bean:write name="detailService" property="status" />or
<bean:define id="theStatus" name="detailService" property="status"/>
     This is country: <%=theStatus%>but an error occured when I tried like this:
String currentStatus = "<bean:define id="theStatus" name="detailService" property="status"/>";
or
String currentStatus = "<bean:write name="detailService" property="status" />";Is there a way to do this?.....
Any help pretty much appreciated

Java != JSP.
The <bean:define> and <bean:write> tags are custom tags meant to appear in the HTML section of a JSP file, as opposed to the scriptlet section. They actually get turned into java code as part of the translation process.
The <bean:write> tag naturally just writes out what you tell it to.
The <bean:define> tag defines a local variable, and gives it a value.
this should do it.
<bean:define id="theStatus" name="detailService" property="status" type="java.lang.String"/>
<%
  String currentStatus = theStatus;
%>With the advent of JSTL, you shouldn't really need to use scriptlet code anymore. Personally I am for 0% scriptlet code in any jsp I write.

Similar Messages

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

  • How to assign a value to the page variable to enable partial page rendering

    This is part of my code:
    <bc4j:rootAppModuleScope name="App1"
    rendered="on@ctrl:page">
    Now, I want to change the value of "on@ctrl:page" to "true" after user click a button so that part of the page will be displayed. But how do I assign the value to "on@ctrl:page". I tried to put the followings in my even handler:
    <bc4j:setPageProperty name="on" value="true">
    <bc4j:parameter name="on" />
    </bc4j:setPageProperty>
    But it doesn't work. Could someone pls tell me how I should do it.
    Thanks a lot!
    Ling

    You should do is:
    in your event handle codes,you add the list:
    public static EventResult eventname(
    BajaContext context,
    Page page,
    PageEvent event) throws Throwable
    EventResult result = new EventResult(page);
    result.setProperty("on","true");//or "false"
    return result;
    then,
    change
    rendered="on@ctrl:page" -> data:rendered="on@ctrl:eventResult"
    also ,you should see the 5th part of 'UIX Developer's Help'

  • How to Open URL value stored in a variable in JSP

    Hi all,
    I want to know how i can use value of a string variable in a JSP as url to open.
    <% String abc="some url value" ; %>
    then i want to open abc as URL in JSP
    Please suggest something on this.
    any help in advance will be highly appreciated.
    thanks,
    savdeep.

    thanks rahul but,
    I want to open the URL in
    <% String URLvariable="abc.htm" ; %>
    <% out.println("< a href=URLvariable>"+rs.getString("Some JSP value")+"</a>"); %>
    please suggest how should i open the above URL value stored in JSP variable.
    any help will be highly appreciated.
    thanks,
    savdeep.

  • Displaying Hashmap values in JSP using struts taglib

    Please can any one provide me the solution for the below query,
    I have stored hasmap key as string and value as arraylist, can any one suggest how to display the hashmap values(arraylist) in table format in jsp using struts taglib.
                             HashMap hsMap=new HashMap();
                             ArrayList arrList = new ArrayList();
                             arrList.add("filesize");
                             arrList.add("filelength");
                              hsMap.put("filename",arrList);
               In jsp i want to display filename and filesize in table format.

    Read this documentation:
    http://struts.apache.org/struts-doc-1.2.x/userGuide/struts-logic.html#iterate

  • How to assigne multiple value in key of read table

    Hi gurus,
    I want read table xxxx with key field1 = ' xxx' or field1 = 'yyy'.
    how to assign multiple value as key for the same field while reading internal table.
    Regards
    sagar

    Hi ,
    You can loop the internal table like
    loop at  <table xxxx> where field1 = ' xxx' or field1 = 'yyy'
    or you can write two read statements to read the internal table in wrk area.
    read table   <table xxxx> with key field1 = ' xxx'.
    if sy-subrc <>0
    read table   <table xxxx> with key field1 = 'yyy'.
    if sy-subrc = 0
    endif.
    else.
    do your data processing.
    endif.
    Thans.

  • How to assign NULL value to an ITEM in Forms Personalization?

    Hi,
    how to assign NULL value to an ITEM in Forms Personalization?
    please suggest me.
    Thanks

    I don't know what your form personalization does and maybe I misunderstand you ...
    Try
    :item_name := null;

  • How to assign a value for Unit of measure (like PC, KG...) in ABAP program?

    Hi,
        How to assign a value for Unit of measure (like PC, KG...) in ABAP program?
        I want to assign PC in a field to execute the program, like wa-ENTRY_UOM = 'pc'.
        But the system returen a message that "Unit of measure  is not convertible to stockkeeping unit PC"
        Could anyone tell me how to assign the value??
        Thanks!

    hi,
    first convert the quantity in the same unit  ( like in you case ST to PC )  by using FM :    MD_CONVERT_MATERIAL_UNIT
    CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
        EXPORTING
          i_matnr                    = matnr
          i_in_me                    = entry_uom
          i_out_me                   = out_uom
          i_menge                    = quantity
       IMPORTING
         E_MENGE                     = fp_l_v_quant
       EXCEPTIONS
         ERROR_IN_APPLICATION       = 1
         ERROR                      = 2
         OTHERS                     = 3.
      IF sy-subrc <> 0.
              give error message here
       ENDIF.
    bcoz in ur program somewhere the quantities etc are compared and there units may be different... so that is why it is showing such error.  so just convert convert the quantity in the same unit  .
    regards
    rahul
    Edited by: RAHUL SHARMA on Jun 17, 2009 9:31 AM

  • How to assign a value to ODI Variable using ODI Procedure

    Hi ,
    Is it possible to assign a value to a ODI Variable using ODI Procedure ?
    If it is possible how we can do that.
    BEGIN
    IF #Counter=1
    Then
    #Next_Increment:=#Counter+1;
    End if;
    END;
    In my example I have 2 ODI Variables #counter and #Next_increment.
    I am trying to assign VALUE TO A ODI VARIABLE #next_increment from another ODI Variable #counter.
    thanks
    prasanna

    Prasanna,
    I have a similar requirement where I need to assign values to ODI variables within a procedure. How do we make use of an ODI package to accomplish this ?
    Actually, I have a sequence of ODI steps, and there is a call to a procedure 'LOG ERROR' from every step which gets called in case error occurs in any step. I just need to identify from which step the error came.
    Please help.

  • How to assign a value to a parameter {?MyParam} dynamically?

    How to assign a value to a parameter {?MyParam} dynamically?
    Example:
      {?One_Or_Two}  <- my first parameter
      {?MyParam}       <- My second parameter
    The Code:
    If ( {?One_Or_Two} = 'One'  then
        {?MyParam}  = 'One' ;
    else 
        {?MyParam}  = 'Two' ; 
    (THIS IS NOT WORKING FOR ME!  ANYONE KNOW WHY?)
      IT NEVER ASSIGN THE VALUE?
    My Command query looks like:
    SELECT * FROM MyTable
        WHERE MyTable.MyColumn = {?MyParam}
    THANKS

    Hi Joseph,
    I'm a bit unclear as to what you are doing and from what I see you're running in circles. 
    Your Command query is looking for a field that is equal to {?MyParam}. 
    Now you want to take {?MyParam} in the report and change the value after you've set it. 
    Parameters cannot be set from the Command, you can format it and manipulate it but they cannot be set except from the parameters window or from a front-end. 
    Thanks,
    Brian

  • Assigning a value to a substitute variable

    Hi, I would like to know if it is possible to assign a value to a substitute variable.
    This is what I'm doing:
    - Prompting user for input
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    (displayed list of options are numbers 0-5)
    - Based on input, open corresponding file
    (start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql)
    Problem:
    - Default selection is 0, meaning use the CURRENT UOM system (a number, 1-5)
    - That being said, &&uom must be assigned a 1-5 value in order to open the file that corresponds to the CURRENT UOM system
    Let me know if any additional information is needed.
    Thanks!

    I apologize for the format. I tried to make it more legible, but was not able to. FYI: It appears to be easier to read in "Edit" view.
    Thanks, I tried the &&uom := your_function(); suggestion, but I am getting an error. It looks like the "value" of &&uom is being read in the assignment statement, not the variable name.
    I have copied the piece of the code, for your reference.
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    DECLARE
    v_uom_sys_selection NUMBER;
    v_curr_uom_sys VARCHAR2 (50);
    v_uom_num NUMBER;
    BEGIN
    v_uom_sys_selection := to_number(&uom);
    v_curr_uom_sys := EG.GET_CURRENT_UOM();
    v_uom_num := eg.get_user_selected_uomnum(v_curr_uom_sys);
    &&uom := to_char(v_uom_num);
    dbms_output.put_line('v_uom_num = ' || v_uom_num);
    dbms_output.put_line('&&uom = ' || &&uom);
    END;
    --prompt "&&uom"
    start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql
    Below are the results I get when commenting out the &&uom := to_char(v_uom_num); line. NOTE: the "value" of &&uom = 0.
    v_uom_num = 1
    0 = 0
    If I leave that line in, I get the following error:
    PLS-00103: Encountered the symbol "0" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier> was inserted before "0" to continue.
    Message was edited by:
    user449676

  • How to pass a value to a BC4J method from JSP/ADF and get a return value.

    How i can access and application module method from my jsp using JSTL passing a value and hope a return value from BC4J method already exposed using interfase and droped from data control to my jsp page
    Any suggestions ?
    Mensaje editado por:
    mr2k

    Hi,
    Check the size of that Window in which you are displaying this Text of 130 characters.
    May be it is less
    in that case split that string into 2 strings and pass the two strings from ITCSY structure to script and use.
    reward if useful
    regards,
    ANJI

  • How do I pass value to 'getURL' url variable

    Howdy,
    I`m trying to launch a popup from a flash form using MX 7
    The popup works fine but I cant for the life of me work out how to pass 'theid' value to the url variable for the popup window.
    I think somthing like this can be done with action script and maybe a cfc but I really dont know how.
    You will notice I referenced 'theid' value directly, I know this will never work but just wanted to show what i was trying to acheive. If I were using a HTML form I could use some javascrip to get the element by id and append the value to the url. Is there away to do this in action script?
    <cfform format = "flash">
    <cfsavecontent variable="ticketpopup">
        getURL("javascript:window.open('supportdetails.cfm?id=#theid#' , 'TicketDetails', 'width=900,height=630, Scrollbars=1, resizable=0'); void(0);");  </cfsavecontent>
    <cfselect name="selectbox" query="thequery" value="id" display="whatever"></select>
    <cfinput type="hidden" name="theid" bind="{selectbox.selectItem.data}">
    <cfinput type="button" name="mybutton" value="whatever" onClick="#ticketpopup#>
    </cfform>
    Any help, much appreciated :-)
    Thanks

    I answered my own question, heres is a solution if anyone is interested..
    You can add the following actionscript to the onChange attribute of the select box. Its passes the value of the selected index to the URL and opens in a new window :-)
    No there is no need for a hidden field or a button either
    <cfform format ="flash">
    <cfselect name="name" query="thequery" value="thevalue" display="whatever">
    onChange="getUrl('supportdetails.cfm?ticketnumber=' + categorysubject.dataProvider[categorysubject.selectedIndex]['data'],'_blank');
    </cfselect>
    </cfform>

  • How to assign a value of the bean to a js variable.

    Hi,
    Im getting some values from the DB which is stored in a list , Now the list is sent across to the jsp through the bean.
    I need to get the length of the list
    I tried something like this.
    <script>         
    var size = <% rmaLicenseTransferForm.slfextUiElements.size(); %>
    </script>rmaLicenseTransferForm is the name of the formBean and slfextUiElements is the name of the list.
    I guess this wont work....by the way i using struts framework.....
    Thanks

    Use the JSTL fn:length tag.

  • How can assign the value returned from javascript to Hidden item

    Hi All,
    I have created a report with button in one column adding following code to SQL select statement like
    SELECT USER_RQST_ID, USER_RQST_DESC, RQST_DATE, STATUS, USER_ID, CNTRY_ID, KPI_LIST, YEAR_LIST, QTR_LIST, MONTH_LIST,
    PROD_LIST, FULL_PERIOD_FLG, GEN_DATE, '<input type=button value="view_list" onclick="javascript:doSubmit('||USER_RQST_ID||');">' button FROM KPI_USER_RQST;
    Then i have implemet doSubmit() function in Javascript like
    function doSubmit(req_id)
    html_GetElement('HIDDEN_ITEM')= req_id.value;
    Here HIDDEN_ITEM is the name of the item, I want to use that HIDDEN_ITEM value in PL/SQL block like...
    BEGIN
    INSERT INTO SAMPLE(KEY) VALUES(:HIDDEN_ITEM);
    END;
    But it is not working, Please help me anybody know the solution How to assign an item in javascript block function.
    Thanks,
    Neel

    Hello,
    doSubmit() is one of the built in javascript functions in apex and it's a bad idea to override it unless you know exactly what you are doing, and even then is a generally bad idea.
    change your function to this
    function mySubmit(pValue){
    $x('HIDDEN_ITEM').value = pValue;
    doSubmit();
    then your onclick will look like this notice the lack of the javascript: and the three ''' quotes to get the proper quotations for your value.
    onclick="mySubmit('''||USER_RQST_ID||''')"
    And there you go
    Carl

Maybe you are looking for

  • How do I delete a file from my USB Stick

    I have a new MacBook Pro with retina display. I have just put in my USB flash drive which contains some movies (MP4 format). I am unable to even move the files to the trash. When I "double click" I only get options to open/ create alias etc When I ho

  • Lost Pictures on iPhoto

    I tried to open iPhoto & saw that all 1,000 of my pictures were gone. I was able to see that they are still on the computer in the iPhoto folder but only available when I open the Preview application. I want to put the pictures back in iPhoto but it

  • .Mac Sync Error and no syncing

    I get a .Mac Sync Error with this notation. *-[NSCFDictionary set: Oject for Key:] nil value I have Synchronized my G-4 to .Mac. In other words .Mac should be the same as my G-4. When I try to sync my iBook and Mac Mini to .Mac I get the above error

  • Migrate local OS X profile to Active Directory account

    I need to add our MACs to our Active Directory domain. How do I go about migrating their settings, preferences, and files to the new AD account? On my test system, when I signed on, it created a new profile and everything had to be reconfigured. How

  • Premiere Pro CC not creating preview files?

    Hi there, I'm working on a project in CC 2014 and when I play a timeline, I either get 'media pending', a black screen or some strange lines as if only a few frames of the clip have properly rendered. When I try to render the timeline, I get "Error c