Using a Variable from web-inf/web.xml in java code?
I would like to create a read-only variable with a value in the /web-inf/web.xml file and then access that value within a java service method within the Application Module.
Where / how do I read the value from the web.xml file and make it accessible within my java code?
thanks
Hi,
you can define context parameters in web.xml that you can access from Java in the web application
The following is a JSF examle that checks a context parameter in a PhaseListener, where the string is stored ina Java constant (could be "myParam")
ExternalContext exctx = FacesContext.getCurrentInstance().getExternalContext();
useSessionPageCache = exctx.getInitParameter(Constants.USE_PAGE_CACHE) == null ? false :
(exctx.getInitParameter(Constants.USE_PAGE_CACHE)).equalsIgnoreCase("TRUE") ? true : false;
From here you can call a method on the AM to set the value or look for another option.
Frank
Similar Messages
-
How to use a variable of jsp custom tag in my java code?
hi folks,
i got a folderList tag like this:
ArrayList list = new ArrayList(20);
%>
<foo:folderList path="${attributes.newsPath}" var="year" contentType="folder">
<%
list.add(${year.contentEntryName}); // of course, this doesn't work
%>
</foo:folderList>I think, its clear what I want to do. I am just wondering how I can use my Variable "year" in the Java code between <% %>...<% list.add(year.getContentEntryName()); %>
You have to have defined in the custom tag that "var" relates to a scripting variable that you want defined.
<tag>
<variable>
<name-given>var</name-given>
<variable-class>myPackage.myClass</variable-class>
<declare>true</declare>
<scope>NESTED</scope>
</variable>
</tag> Cheers,
evnafets -
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 PMIf nothing else, why not just have your servlet load a configuration file on startup?
-
Move env-entry from web.xml into deployment plan
I have:
<env-entry>
<env-entry-name>USERNAME</env-entry-name>
<env-entry-value>someUser</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
and I'd like to move it from web.xml into my_app_plan.dat. Is it possible? How?
Thank you in advance!Let me describe my case in few more words...
I have some kind of client-server app. Clients have OC4J installed and they download myApp.ear and myApp_plan.dat files and by using script (Windows CMD batch file) clients install those files with admin_client.jar, OC4J's admin utility. The problem is that I have 2 different types of clients and I have client specific settings set in web.xml file and each time I compile myApp.ear I have to uncomment/comment some lines in web.xml.
So, to make a long story short, I need a way to deploy those settings separated from (outside of) myApp.ear. By following you link, I have read that orion-web.xml should reside inside WEB-INF folder of myApp.ear, which is not good for me. -
Simplest way to modify properties from web.xml
I'm testing a very small Web application which uses init-params in web.xml for configuration. For manual testing purposes, I need to be able to change the values of these as easily as possible, preferably from the WebLogic admin console. (I can do it from the console on Websphere App Server, and on Tomcat by editing a file which is immediately re-read.) We don't currently use deployment descriptors in any way and this is only a test of basic code functionality, not of deployment mechanisms, so the change can be as quick-and-dirty as you like. I'm using WebLogic v10 on Linux.
Thanks,
PeteAnother option for you may be to deploy the application in exploded format and use weblogic.Deployer or WLST to redeploy the application :
http://edocs.bea.com/wls/docs100/deployment/autodeploy.html
This would be slightly more similar to your Tomcat deployment, but requires a few more steps. -
How to get parms from web.xml?
Hello,
I want to store some config parms in web.xml and read them from within JSP.
What is the syntax for the web.xml and the code needed in JSP to read it?
Thanks
FrankGlobal parameters:
<context-param>
<param-name>myParam</param-name>
<param-value>1</param-value>
</context-param>
//Accessing in a servlet
getServletContext().getInitParameter("myParam");
// in a JSP
<%
application.getInitParameter("myParam");
%>
// using JSTL
${initParam.myParam} -
Binding xml from web service to java objects
I would appreciate if someone can tell me where can i get information regarding
binding of xml from web service to java objects in weblogic 6.1 .
Thanks,
agHi Ag,
To my knowledge, the only information on this topic is whatever you find in the
documentation. What exactly do you want to know?
Can you post a set of specific questions?
Regards,
Mike Wooten
"ag" <[email protected]> wrote:
>
I would appreciate if someone can tell me where can i get information
regarding
binding of xml from web service to java objects in weblogic 6.1 .
Thanks,
ag -
How do I use a variable from an Interface class?
Right now I have three classes. First class is called Game and it extends my second class call Parent and also implements my third class call Source. Source is an interface class. I have a variable that I want to use in my Source class named Checker. Now, How do I go among using that variable from my Game class? What should the code look like?
ex.
public class Game extends Parent implements Source
need help badly....ok, what I forgot to tell you guys is that my variable
in my interface class is a boolean type(true or
false). It is set to true now. But I want it to change
to false when a user triggers a button in the Game
class. How do I do this? You don't because you can't. If you have a varaible declared in an interface it must be static and final. It cannot, therefore, be changed. Better head back to the drawing board. -
Pass the data back from the jsp page to the java code
Hi,
I have written an iView that receives an event using EPCF and extracts data from the client data bag.
I need this iView to pass the data back from the jsp page to the java code.
I am trying to do this using a hidden input field, but I cannot get the code to work.
Here is the code on the jsp page.
<%@ taglib uri="tagLib" prefix="hbj" %>
<hbj:content id="myContext" >
<hbj:page title="PageTitle">
<hbj:form id="myFormId">
<hbj:inputField id="myInputField" type="string" maxlength="100" value="" jsObjectNeeded="true">
<% myInputField.setVisible(false);%>
</hbj:inputField>
</hbj:form>
</hbj:page>
</hbj:content>
<script language=JavaScript>
EPCM.subscribeEvent("urn:com.peter", "namedata", window, "eventReceiver");
function eventReceiver(eventObj) {
var url = eventObj.dataObject;
var funcName = htmlb_formid+"_getHtmlbElementId";
func = window[funcName];
var ipField = eval(func("myInputField"));
ipField.setValue(url);
var form = document.all(htmlb_formid);
form.submit();
</script>
Here is my java code
package com.sap.training.portal;
import com.sapportals.htmlb.InputField;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
public class ListSalesOrder extends PageProcessorComponent {
public DynPage getPage(){
return new ListSalesOrderDynPage();
public static class ListSalesOrderDynPage extends JSPDynPage{
private String merong;
public void doInitialization(){
public void doProcessAfterInput() throws PageException {
InputField reportfld = (InputField) getComponentByName("myInputField");
if (reportfld != null) merong = reportfld.getValueAsDataType().toString();
public void doProcessBeforeOutput() throws PageException {
if ( merong != null ) setJspName("merong.jsp");
else setJspName("ListSalesOrder.jsp");
Here is DD
<?xml version="1.0" encoding="utf-8"?>
<application>
<application-config>
<property name="SharingReference" value="com.sap.portal.htmlb"/>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
</application-config>
<components>
<component name="SearchSalesOrder">
<component-config>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="/pagelet/SearchSalesOrder.jsp"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
<component name="ListSalesOrder">
<component-config>
<property name="ClassName" value="com.sap.training.portal.ListSalesOrder"/>
</component-config>
<component-profile>
<property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
</component-profile>
</component>
</components>
<services/>
</application>
After receive event, then call java script function "eventReceiver" and call "form.submit()".
But .. PAI Logic in Java code doesn't called ...
Where is my problme ?
Help me ...
Regards, Arnold.Hi Arnold,
you should not do a form.submit yourself. Instead you can put a component called ExternalSubmit to your page:
ExternalSubmit exSubmit = new ExternalSubmit("EX_SUBMIT"));
exSubmit.setServerEventName("MyEvent");
This results in a java script funtion on the page which is called "_htmlb_external_submit_". If you call this function the the form gets submitted and your event handler is called.
regards,
Martin -
JavaScript is not from the same origin as the Java code
When trying to log into my school website with Safari, I get the following error from the console:
sun.plugin.liveconnect.OriginNotAllowedException: JavaScript is not from the same origin as the Java code, caller=http://tychousa3.umuc.edu/WebTycho.nsf/setJVMCookie?OpenPage, callee=https://tychousa3.umuc.edu/sys/
This keeps me from logging in. In order to get it to work, I have to disable Java, log in, then reenable Java after logging in.
I am able to log in successfully with Firefox but I really prefer to use Safari.
Does anyone else experience this problem and do you know how to fix it? Any help would be very much appreciated. Thanks.
iBook 933 - PPC Mac OS X (10.4.5)I'm reposting. No answer.
-
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.
-
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.
paulsepNothing 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> -
Env-entry from web.xml not in generated plan.xml
Hello,
Recently I migrated a JDeveloper 10.1.3.4 project to 11.1.1.3 and from there to 11.1.2.4. When I deploy this project to an 10.3.5. weblogic server then the 'env-entry' entires in the web.xml are not available on the application server.
Even when i use weblogic.PlanGenerator with the -all option to create a plan.xml from the WAR-file the env-enties are not found.
The web.xml is like this:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<listener>
<listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>jaxrpc</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>VersionServlet</servlet-name>
<servlet-class>nl.deltalloyd.alfa.keten.version.VersionServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>VersionServlet</servlet-name>
<url-pattern>/version</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jaxrpc</servlet-name>
<url-pattern>/RelatieSoapHttpPort</url-pattern>
</servlet-mapping>
<jsp-config/>
<security-role>
<role-name>Administrators</role-name>
</security-role>
<resource-ref>
<res-ref-name>jdbc/AlfaDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<env-entry>
<env-entry-name>appl/version</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>2013.06</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>appl/releasedate</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>13-06-2013</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>appl/loglevel</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>INFO</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>appl/omgeving</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>service/case</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>http://test.services.intranet.company.nl/GixoCaseWeb/services/CaseServiceHttp</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>mqueue/rc/host</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>nl001wwavm058.ad.intra</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>mqueue/rc/port</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>1414</env-entry-value>
</env-entry>
</web-app>
Maybe I missed something in the migration path. Can someone please help me.
With kind regard,
MartinLet me describe my case in few more words...
I have some kind of client-server app. Clients have OC4J installed and they download myApp.ear and myApp_plan.dat files and by using script (Windows CMD batch file) clients install those files with admin_client.jar, OC4J's admin utility. The problem is that I have 2 different types of clients and I have client specific settings set in web.xml file and each time I compile myApp.ear I have to uncomment/comment some lines in web.xml.
So, to make a long story short, I need a way to deploy those settings separated from (outside of) myApp.ear. By following you link, I have read that orion-web.xml should reside inside WEB-INF folder of myApp.ear, which is not good for me. -
Problems using substitution variable in Web Analysis
Dear all,
I have a Web Analysis report that I need to show a raking table with the current month.
For that I create a variable in Essbase that is updated with that date (E.g.: varCurrentMonth).
After that I use it as my substitution variable to filter my date dimension in a report data source (E.g.: Scr5, row: product, column: date dimension & measure):
2008 (current month)
Product $ qty.
AAA 100 10
BBB 90 7
CCC 80 5
The problem is that in our cube we need to use an alias in every dimension not to have duplicate members (E.g.: DT.Date, MS.Measure, PD.Product, etc). And when we use it we need to set up the variable in Essbase using that alias (E.g.: DT.Feb/05/08). And if we use that variable as a substitution variable in the report data source the label displayed is the DT.2008 and not 2008 as expected.
Does anybody have an idea how to solve that?
Many thanks,
Thiago GabrielYou usually get this error message if you are trying to assign a value from a sub var to a member that does not exist.
e.g. trying to put FY08 which is a year member against a period dimension
or trying to use a sub var of FY09 which does not yet exist in the essbase, so say you added a new year in planning FY09 and used the sub var in the form but have not refreshed the database then it would fail because the year would not have been pushed down to essbase yet.
or the value of the subvar does not match a member name exactly
or using a sub var name that does not exist in essbase, e.g. using &nextYear but the sub var has not been created in essbase.
You can definitely use subsitution variables in columns in the version you are using and prior version.
Cheers
John
http://john-goodwin.blogspot.com/ -
Validation error when using env-entry in web.xml
I've added an env-entry element to my web.xml and it falls over at deploy time with a validation error. However, from what I can see, this is valid based on the schema.
And infact, it matches the example in the weblogic doco - http://edocs.bea.com/wls/docs103/webapp/web_xml.html#wp1025195
The error I'm getting is:
<17/12/2008 11:45:56 AM EST> <Error> <J2EE> <BEA-160197> <Unable to load descriptor D:\workspace\source_checkout\investment_control\ic-web\src\main\webapp/WEB-INF/web.xml of module ic-web.war. The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
problem: cvc-complex-type.2.4a: Expected elements 'mapped-name@http://java.sun.com/xml/ns/javaee injection-target@http://java.sun.com/xml/ns/javaee' instead of 'env-entry-type@http://java.sun.com/xml/ns/javaee' here in element env-entry@http://java.sun.com/xml/ns/javaee:<null>
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:234)
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:221)
My web.xml looks like:
<web-app 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/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<description>IC Web</description>
<env-entry>
<env-entry-name>aEntry</env-entry-name>
<env-entry-value>aValue</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
Any suggestions???Found a resolution to this in the end.
Unless you have the sub-elements in the order below, it will get validation errors.
<env-entry>
<env-entry-name>maxAmount</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>aString</env-entry-value>
</env-entry>
A bit weird and very frustrating....
Maybe you are looking for
-
SAP CRM integration to non sap Portal
Hi all, my customer asks me the following questions. Could please help me to better understand his doubles ? 1. Do the iViews necessarily have to run in environment SAP EP to be visualized in WSP or they can directly be performed in WSP ? 2. The cust
-
I use InDesign CS6, I was told that if i hold the ALT key down and double click on a picture it will be opened in Photoshop. When I do it, it opens in Windows Photo Viewer. How do i get it to open in Ps?
-
Hi Gurus, Can somebody help us configure the output medium as mail. We have a requirement where by the user wants to receive the output via mail and in the PDF format. Please let us know if there is any standard functionality for this or else Please
-
No fund derived for stadistical commitment item: error F6804
Hello, While posting a payment I face an exchange difference. The exchance difference account has an "stadistical commitment item" related in the GL master data. While posting and following the fmderiver tracking I see that the account tries to get t
-
Delete a version --- what am I doing wrong?
Hello everyone. I'm using Aperture 1.5.1. I have a NEF file that I sent to Photoshop Elements 4.0 as a TIFF to do some editing. This was done through the 'Open with External Editor' command. Upon returning to Aperture, I found the file as edited stac