Access custom variable value in web.xml context-param?

My requirement or need is to access a variable value either in a class in my Model project or a backing bean in my View project. For example, one variable I need to access is an application server I am integrating with - 'testserver' or 'productionserver' - I want to be able to configure this within an external file so that I do not have to re-compile my application to change the variable.
I was thinking about placing this variable in the web.xml <context-param> section as:
<context-param>
<param-name>servername</param-name>
<param-value>testserver</param-value>
</context-param>
I need to access this value within a class (not a servlet) on an Application Module service method, though if needed, I could access it from a backing bean and pass it to the service method (less desirable.) Is this a good approach and how do access this variable from within a Java class including any imports I need to do (code example)?
Thanks and Happy New Year!
Hopefully most everyone is out spending time with friends and family versus stuck trying to complete a project like me...

I found an example from SRDemo that provides what I was looking for:
String serverhostaddress =
FacesContext.getCurrentInstance().getExternalContext().getInitParameter("param-name-var-in-webxml");

Similar Messages

  • 9.0.3, web.xml, context-param

    Using documentation found on oracle's website, where I needed to have a specific initialization parameter, I setup a context-param in web.xml. In 9.0.2, I got a warning (and posted here but got no response) but was able to continue. In 9.0.3 I can't run my project when I include this parameter.
    Here's what I add to web.xml
    <context-param>
    <param-name>ReportServerURL</param-name>
    <param-value>http://localhost:8888/reports/rwservlet</param-value>
    </context-param>
    when trying to compile, I get:
    Error(76,18): Invalid element 'context-param' in content of 'web-app', expected elements '[taglib, resource-ref, security-constraint, login-config, security-role, env-entry, ejb-ref]'.
    Any ideas?
    Thanks,
    Jeff

    If only you would see web-app.dtd you could know that context-param must be enclosed in web-app and be at certain place. See that (from web-app.dtd):
    <!ELEMENT web-app (icon?, display-name?, description?, distributable?,
    context-param*, filter*, filter-mapping*, listener*, servlet*,
    servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?,
    error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*,
    login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>

  • Web.xml context-param problem...

    Hi all,
    Thoes anyone know how to set CHECK_FILE_MODIFICATION in web.xml param permanently, because whenever I set it on true, after few moments it's back on false?
        <context-param>
            <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
            <param-value>true</param-value>
        </context-param>Regards,
    s o v i e t

    Hi Soviet,
    We suffer from the same bug (which is very annoying) on our project too. One of the exasperated team member fixed it by saving the value to true then removing the write right on that file at OS level... It's a hardcore fix, but it works.
    Regards,
    ~ Simon

  • Need help to set values from web.xml in a jsp class

    Hey :-)
    I`m trying to get value from my web.xml file into a jsp class. The problem is that the value always retur null. My web.xml file is replaced in the WEB-INF directory where should be. Here is my web.xml
    <servlet>
    <servlet-name>Html</servlet-name>
    <servlet-class>Html</servlet-class>
    <init-param>
    <param-name>html_test</param-name>
    <param-value>Value I want have in my jsp class
    </param-value>
    </init-param>
    </servlet>
    And her i my java class who don`t work:
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.servlet.ServletConfig;
    public class Html extends BodyTagSupport
    String title="";
    String html_test;
    ServletConfig config;
    public void doInitBody() throws JspException
    html_test = config.getInitParameter("html_test");
    }//End of method doInitBody()
    public int doStartTag() throws JspException
    try
    JspWriter out = pageContext.getOut();
    out.print( "<HTML>\n" );
    out.print( "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" );
    out.print( "<BODY>\n" );
    out.print( "<BR><H1>" + html_test + "</H1>" );
    And here are my html_test variable return null.
    I hope somone can help me, duke dollars will be given away for the solution answer.
    paulsep

    Nothing seems to work, have change the string and rewritten the web.xml file to:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
              <context-param>
                   <param-name>html_test</param-name>
                   <param-value>Value I want have in my jsp class</param-value>
              </context-param>
    </web-app>

  • Variable values in composite.xml property

    Hi, i've got the similar proble to: variable values in composite.xml property
    Static value for property
    <property name="oracle.webservices.auth.password" type="xs:string"
    many="false" override="may">admin</property>
    <property name="oracle.webservices.auth.username" type="xs:string"
    many="false" override="may">admin</property>
    Expect result:
    <property name="oracle.webservices.auth.password" type="xs:string"
    many="false" override="may">$variable</property>
    <property name="oracle.webservices.auth.username" type="xs:string"
    many="false" override="may">$variable</property>
    i've probe the suggestion but cant get the specific solution.... may soneon can't help me!!

    Hi
    Thank you for the reply, I also would like to use the DVM solution to get the dynamic values, but the problem is how should I use this variable after this variable get the value from DVM?
    Does it have a property to override "oracle.webservices.auth.username" property or how could I use "oracle.webservices.auth.username" to get the variable value?
    I'm not sure if you understand my question, feel free to let me know.
    Thanks again for your reply.

  • Display variable values in Web report

    Hi Bw Mates,,,
    I am trying to display the variable values in Web Report.
    I put one text Item in Template and checked the Variable Display and entered the variable name in List.
    still I cannot see the variable values in the report.
    Thanks for your help.
    RSB

    <object>
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TEXTELEMENTS_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_TEXT_ELEMENTS"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="GENERATE_LINKS" value=""/>
             <param name="GENERATE_CAPTION" value="BORDER"/>
             <param name="SHOW_COMMON_ELEMENTS" value=""/>
             <param name="ELEMENT_TYPE_1" value="VARIABLE"/>
             <param name="ELEMENT_NAME_1" value="Z_CP_018"/>
             ITEM:            TEXTELEMENTS_1
    </object>
    as the other poster mentioned the variable name has to be in upper case.
    if only_values = 'X' you will just get the value other wise
    you will get something like below.
    variable description = variable value
    Regards
    Raja
    Reward the helpful answers and close the thread once its answered.
    sorry for the delay in answering, it was weekend for us

  • Retain variable values across web templates during a web session

    Hi all,
    How can we let web template get variable values from another template's variable values so as to keep the same entry values as previous report run?
    For example 0vendor has a variable (for single, mandory) used in all  vendor related web templates. "vendor1" was entered for the second template.
    I tried to use "SET/GET PARAMETER" in variable user exit. It works in BI with RSRT,  but it doesn't work with Bex or Web template. Looks like web session is not sync with the ABAP stack.
    How about using cookie? How to create/reset cookie in variable user exit? Can we get variable values from web server memory or user session data?
    Please share your thought !
    Thanks for helping!
    David

    Hi Arun,
    All the web templates are randomly run by user, there are no set of templates run after one template. Any templates can run after any other web template.
    Basically we link  web templates with portal menu items. any report can be run by any sequence. The thing the new report need to take the previous selection values from common variables.

  • Using Variable in Web.xml/ Override value in web.xml

    Environment : JBOSS 4.2 / Web application in java/jsp
    *==============================================================*
    Iam using a servelet in application, and paremeters is configured in web.xml at run time I need to change the value. A variable
    see web.xml
    {color:#ff0000}<param-value>C:/FILE_ATTACHMENTS{color}</param-value>
    Instead of using a static folder name I need to use a variable, this veriable either i define in config.properties or ineed to pass through application
    Web.Xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="[http://java.sun.com/xml/ns/j2ee]" xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance]" xsi:schemaLocation="[http://java.sun.com/xml/ns/j2ee] [http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd]">
    <display-name>VyasaWeb</display-name>
    <servlet>
    <servlet-name>VyasaServlet</servlet-name>
    <servlet-class>com.jsos.download.VyasaServlet</servlet-class>
    <init-param>
    <param-name>dir</param-name>
    param-value>C:/FILE_ATTACHMENTS</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>VyasaServlet</servlet-name>
    <url-pattern>/servlet/VyasaServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    Is any way to use variable in web.xml or override the value ?
    Please help
    Vince
    Edited by: VINCEJOHNSON on Jul 30, 2010 3:30 PM

    If nothing else, why not just have your servlet load a configuration file on startup?

  • How to initialized a variable in java file by taking the value from web.xml

    suppose i declare parameter in web.xml file
    i want to access if from a java file .
    how can i do this . plz help me its urgent...............

    In your Servlet class you can use the getInitParameter("configfile") method.

  • Getting Email Value from web.xml and displaying in JSF

    HI,
    I have a web.xml with the entry:
    <env-entry>
            <description>The email address for the Support Team.</description>
            <env-entry-name>support</env-entry-name>
            <env-entry-type>java.lang.String</env-entry-type>
            <env-entry-value>[email protected]</env-entry-value>
    </env-entry>I want to display on the JSF the value *"[email protected]"*. I dont want to Hard Code the Email Id on the JSF hence I am looking for this solution.
    One way would be to get the value of the email in a backing bean and then setting a managedBeanValue which will be accessed in the JSF Display page.
    My question is how do I get the email value in my backing bean ?
    Thanks in advance !!!

    I tried using this code:
        FacesContext context = FacesContext.getCurrentInstance();
        ServletContext servletContext = (ServletContext)context.getExternalContext().getContext();
        String value = (String)(servletContext.getAttribute("support");But when I do a System Out on value I get null
    Please Help.
    Thanks in advance

  • Edit env-entry values from web.xml in the WLS console.

    Hi guys!
    Is it possible to define JNDI variables of type java.lang.String using WLS Console?
    Thanks

    I think this would require the use of a deployment plan, which you can learn about here: [http://e-docs.bea.com/wls/docs103/deployment/config.html] . This won't be as convenient as just editing the value directly in the admin console. In fact, it won't even prevent the requirement of redeploying the webapp. It will only allow you to make the change without rebuilding and repackaging the webapp.
    It's questionable whether it's practical or meaningful to change env-entry values in a web.xml without redeployment, because even if you could change the values without redeploying, you'd have to reinitialize the servlet/filter with the changed environment parameter.
    If you really need this dynamic reconfiguration ability, you might have to design the facility into your application, using some sort of polling or event handling capability.

  • How to set variable value in an XML array

    Hi,
    Please let me know how to set the value for a xml array element using assign activity inside a for-each block in BPEL 11g
    I tried to set the variable value for result element using the below condition but i encountered selection failure message
    $outputVariable.payload/ns1:Student['i']/ns1:result or
    $outputVariable.payload/ns1:Student[$i]/ns1:result
    And the xsd used is as below
    <xsd:complexType name="StudentCollection">
    <xsd:sequence>
    <xsd:element name="Student" type="Student" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="Student">
    <xsd:sequence>
    <xsd:element name="Name" type="xsd:string"/>
    <xsd:element name="location" type="xsd:string"/>
    <xsd:element name="mark" type="xsd:string"/>
    <xsd:element name="result" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    Thanks,
    Dhana

    Hi,
    At the back of button specify the following parameter:-
    CMD    1        Execute_planning_function
    Planning_function_name  1   xyz
    Var_name     1    variable_name
    var_value      1    blank
    Can also refer to link below:-
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0a89464-f697-2910-2ba6-9877e3088954?quicklink=index&overridelayout=true(can refer to page 20)
    http://www.sdn.sap.com/ddc5564a-337d-4cf9-a34e-2dab64df09be/finaldownload/downloadid-a61a6724ba8e7b7fbd9c5df9590ab50d/ddc5564a-337d-4cf9-a34e-2dab64df09be/irj/scn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be?quicklink=index&overridelayout=true
    Hope it may help

  • Importing a text file with variable values into web reporting

    Hello,
    I'm looking for a possibility to import values from a text file into a variable selection in Web reporting.
    With BEx reporting in Excel this is possible, by clicking on the multiple selection button in the variable popup screen, and subsequently selecting the "Import from Text file" button.
    However, this function seems not to be available for web-reporting...
    It would be great if someone could help me out with this!
    Thanks & regards,
    Arvid

    Hi,
    we could resolve this issue, so i thought it may also be helpful for others:
    In our example we used a file with numbers for materials. This file is stored somewhere in a directory, to which SAP BI must have authorization to read.
    The file looks something like this:
    4711
    4712
    4713
    4714
    The file is named "import.txt" and lays in directory "/usr/sap/EC6/files/bi/"
    *&  Include           ZXRSRU01
    * global variables
    Data: intern_range LIKE LINE OF i_t_var_range,
          l_s_range    TYPE rsr_s_rangesid,
          line(100)    TYPE c,
          p_file(128)  TYPE c,
          length_rangelow  type i,
          tmp_rangelow     like l_s_range-low.
    * internal tables for selection-transfer from transaction
    * Data: BEGIN OF it_file occurs 0,
    *        it_p_file(128) TYPE c,
    *      END of it_file.
    IF i_step = 1.
    ** variables can be changed or set before pop-up appears
      CASE i_vnam.
    * take material from external file to selection-list
         WHEN 'ZSD_UPMA'.
    ** call of transaction, with which the path can be set
    *CALL TRANSACTION 'ZBW_VARIABLE' using it_file
    *MODE 'A'      " call should be visible, so that variable can be set
    *UPDATE 'S'.   " first transaction, then processing
    ** Der Pfad, der in dem Selektionsbild eingegeben wird, wird an die Variable übergeben
    ** Der Set-Parameter ist in Report ZSD_SELECT_VARIABLE
    *  get parameter id 'VAR' field p_file.
    p_file = '/usr/sap/EC6/files/bi/import.txt'.
    * further handling of variable in BI
          OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
          IF sy-subrc = 0.
            READ DATASET p_file INTO line.
            WHILE sy-subrc = 0.
              IF line(2) <> '//'.
                l_s_range-sign = 'I'.
                l_s_range-opt  = 'EQ'.
                l_s_range-low  = line.
    * fill with leading Zeros
    * in variable tmp_rangelow the value from l_s_range-low is taken
        tmp_rangelow    = l_s_range-low.
    * read the length
        length_rangelow = strlen( tmp_rangelow ).
    * in our case: material has 18 characters
        while length_rangelow lt 18.
          CONCATENATE '0' tmp_rangelow INTO tmp_rangelow.
          length_rangelow = length_rangelow + 1.
        endwhile.
    * initialize l_s_range-low
        clear l_s_range-low.
    * set with filled values
        l_s_range-low = tmp_rangelow.
    * transfer to structure
                APPEND l_s_range TO e_t_range.
              ENDIF.
              READ DATASET p_file INTO line.
            ENDWHILE.
          ENDIF.
          CLOSE DATASET p_file.
        ENDCASE.
    ELSEIF i_step = 2.
    ** in step 2 all variable values from pop-up input can be processed or
    ** User Exit variables can be derived
    * UserExit Ende.
    ENDIF.
    Hope i could help!
    Best regards,
    Tobias

  • How I can gain the variable value in web-application?

    Hi,
    I have a web-template with several web-item. The data provider refers to a query with a variable screen.
    After the report run and the table is displayed, i have need to set a paticular filter-item with the variable value that i put in pop-up screen.
    Therefore I am trying a function or method in order to pass the variable value (pop-up variable).
    Help me, Thanks in advance

    Hi Ciro,
    in the Web item properties of the Text element web item you can specifically select in the ITEM_LIST a list of text elements. For variables you can choose if you want to display text or key values. This should work for the print template.
    With the Excel display I'm a bit unsure. There is a BEx Function called SAPBEXshowTextElements that allows you to display the variable values. I just don't know if you can execute it in the SAPBEXonRefresh. You can find additional information in the BW help under Business Explorer->Analysis & Reporting: BEx Analyzer->Queries in Workbooks->Integration with Visual Basic for Application (in the BW 3.1 documentation).
    Another thing that might work is to add another navigational attribute to the needed InfoObjects with reference to the InfoObject. While loading Master Data you can fill the navigational attribute with the same value as the characteristic. Then you can drag the variable into the filter and put the Navigational attribute into the query.
    Example: You have the IO 0COSTCENTER that you want to put a filter on. Create an IO COSTC_N (Costcenter Navigation) with reference to 0COSTCENTER and insert it into 0COSTCENTER as navigational attribute. While loading Master Data for 0COSTCENTER fill COSTC_N from 0COSTCENTER.
    In the query put COSTC_N into the filter box and create a fitting variable. 0COSTCENTER can now be displayed in the rows and the filter values for COSTC_N are displayed in the query.
    Best regards
       Dirk

  • Accessing custom tag value in scripting code

    Hi All,
    How can i access my custom tag value in scripting code?
    For example, assuming my tag is <myTag:display value="myValue"/>, how can i System.out this value in scripting code? I wanna do <% System.out.prinln(xxx); %> where xxx should be my custom tag value.
    Thanks in advance,
    Leo.

    I understand that you want to store "myValue" somewhere accesible by scripting. The more easy and portable way is to store that value in an attribute, for instance:
    <myTag:display value="myValue" var="myVar" scope="session"/>And in the custom tag code:
    // translate scope string to PageContext scope values
    pageContext.setAttribute(var, value, scope);This ensures compatibility with Java Standard TagLibrary and EL:
    <c:out value="${myVar}"/>And finally, scripting:
    <% Object value = pageContext.findAttribute(var); %>

Maybe you are looking for

  • How do I run iCal 1.5 on an intel mac or fix iCal 2.0 webdav publishing?

    I've been using iCal 1.5 (any version, 1.5.2, 1.5.5, etc) to publish to a zope server using webdav for a few years now. I just bought a new Mac Pro, and discovered that while iCal 2.0 still publishes using webdav, the zope server is no longer able to

  • ITunes won't install or recognize my iPhone 4 on a new laptop computer

    I keep getting an error that iTunes can't install b/c there are not the correct permissions and there is an unknown error.  I Keep downloading the new itunes software, it gets to a certain point then says it can't continue and rolls back and tells me

  • Problem connecting to MySQL thro Applet using JDBC

    Hi, I'm trying to use an applet to connect to MySQL thro JDBC. The applet, the IE client that loads the HTML, and MySQL all reside on the same machine. But I'm getting the following error:"ClassNotFoundException: com.mysql.jdbc.Driver". But I'm able

  • Help changing fqdn?

    When I set up my server, I used the fqdn for our school website, which was fine except that the website is hosted elsewhere, and so when someone inside the school tries to go to school website (which I would like everyone to use as home page) the ser

  • Why are there shadows at the bottom of my screen?

    why are there shadows at the bottom of my screen and how do I get rid of them?