I am using JSF 1.2 for my application. I am trying to create a separate config file (named: navigation-config.xml) for all the navigation rules throughout my application. Below are the steps I followed for the same:
Made an entry in the web.xml file and placed it same directory where the faces-config.xml is present:
<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/navigation-config.xml</param-value>
</context-param>
Below is the content of navigation-config.xml :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<navigation-rule>
<description>Welcome Screen Navigation</description>
<from-view-id>/login.jspx</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/welcome.jspx</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
When success, the navigation is not happening. If I remove the <navigation-rule> from the navigation-config.xml and add it to my faces-config.xml file then the navigation is working perfectly which means there are problems with the navigation-config.xml file navigation is having problems.
Please let me know how to resolve this, I need a separate file indicating all the navigation rules.
Try following...
make changes in web.xml file
> <context-param>
> <param-name>javax.faces.application.CONFIG_FILES</param-name>
> <param-value>/WEB-INF/faces-config.xml</param-value>
> <param-value>/WEB-INF/navigation-config.xml</param-value> </context-param>
Related
I have a main file (main.jsp) which includes multiple other JSPs.
I've added some servlet mapping to main.jsp to change the url from:
folder/appname/main.jsp
to:
appname/
Here is my web.xml:
<servlet>
<servlet-name>Main</servlet-name>
<jsp-file>/folder/appname/main.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>Main</servlet-name>
<url-pattern>/appname/</url-pattern>
</servlet-mapping>
The problem however, is that when I load this page i get the following error
java.io.FileNotFoundException: /page_modules/included_file.jsp
The file above is included in the main.jsp like so:
<jsp:include page="page_modules/included_file.jsp" />
Folder structure as requested:
Dynamic Web Project
>Java Resources
>src
>com.project
>servlet
>WebContent
>forms
>folder
main.jsp
>page_modules
included_file.jsp
Try using code like
<jsp:include page="/page_modules/included_file.jsp" />
Or
<jsp:include page="/forms/folder/page_modules/included_file.jsp" />
I recently tried to convert an Eclipse, Google Appengine Project from java7-java8 since GAE has stopped supporting java7 (or will do in the near future).
The project was working fine before starting the conversion. I am now getting this error when trying to run the project locally:
java.lang.IllegalStateException: Multiple servlets map to path: /api/add-batch-shelfsurvey: ApiShelfSurveyBatchServlet,com.imobdev.figjam.ApiShelfSurveyBatchServlet
This is the entry in web.xml for that servlet:
<servlet>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<servlet-class>com.imobdev.figjam.ApiShelfSurveyBatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<url-pattern>/api/add-batch-shelfsurvey</url-pattern>
</servlet-mapping>
This is the start of the web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
I've double and triple checked /api/add-batch-shelfsurvey path is unique in web.xml but I still get this error.
The servlet mentioned in the error message changes but none of them have multiple mappings to one path.
I've found these threads that seem similar but aren't actually related:
https://github.com/dropwizard/dropwizard/issues/2107
https://bugs.eclipse.org/bugs/show_bug.cgi?id=479865
I don't know if it's relevant but this is my appengine-web.xml file:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="appengine.file.encoding" value="US-ASCII"/>
</system-properties>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
</appengine-web-app>
It is because the path
/api/add-batch-shelfsurvey
might have been registered before try to check all
<servlet-mapping>
sections in web.xml and if you have any
#WebServlet annotations then check urlPatterns={"..."}
If you have two definitions at the same time app server will not know which is the right one.
I've managed to get the project to run on the localhost and upload and run on Google App Engine. Unfortunately I don't know exactly what the problem was.
These are the steps I took:
-Removed the /* from all in web.xml file.
-Changed between version 2.5 xsd and 3.1 xsd several times, running the project on localhost each time.
-Changed back to 2.5 xsd and changed all back to ending in /*
Project then compiled and ran fine on both localhost and appengine. If anyone knows anything more about why this might happen please let me know.
I have been getting the following JasperException when trying to use an XML schema for my web.xml, instead of the deprecated DOCTYPE declaration:
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core
cannot be resolved in either web.xml or the jar files deployed with this
application
If I use this web.xml, the application compiles:
<!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>
<display-name>Archetype Created Web Application</display-name>
</web-app>
However, if I use this web.xml, I get the JasperException:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>CourseManagementJDBC</display-name>\
</web-app>
Any idea why only a deprecated format would work?
NOTE: This is for a Maven project, and the JSTL dependency has been correctly declared, as well as the tag library in the JSP:
pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
JSP:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
They're all correct; what gives?
I finally came upon the solution. By default, for some reason (and I'd like to know why), Maven generates a Dynamic Web Module as version 2.3. DTD was of course the standard for Servlet 2.3 and was probably unable to parse or evaluate my XML-based web.xml file.
I'm still not 100% clear as to why changing web.xml to XSD caused the JasperException with respect to JSTL, though I think it has something to do with JSTL being integrated with JSP at some point after Servlet 2.3 - someone please correct or elaborate on this if possible.
See this: https://stackoverflow.com/a/4928309/2879303
Now for the solution:
Right-click on your Maven project and select Properties
Navigate to Project Facets and untick Dynamic Web Module. Apply
changes.
From the version drop-down box, select the latest version (as of
writing, this is 3.1). Re-select Dynamic Web Module. Apply changes.
Right-click on your Maven project and select Maven -> Update
Project.
Your project should now be able to correctly interpret a web.xml
with an XSD declaration.
I'm using Rational Application Developer 8.5 to develop a custom workflow action plugin for IBM Web Content Manager (WCM) in WebSphere Portal 7.0.
The plugin needs to get a JDBC data source with JNDI, but all my attempts to do so produce this error:
javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
A data source named "jdbc/wcmbulletins" is defined in the WebSphere Application Server.
Here's the java code to get the data source:
javax.naming.InitialContext ctx=new javax.naming.InitialContext();
javax.sql.DataSource ds=(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/wcmbulletins");
The RAD project contains the following XML files only. There's no "persistence.xml" or any other files I've seen mentioned in similar SO questions.
There are also some JSP files referenced by WCM JSP components. The JSP files have no connection with the plugin and don't use JNDI or JDBC.
ibm-web-bnd.xml:
<web-bnd
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host"/>
<resource-ref name="jdbc/wcmbulletins" binding-name="jdbc/wcmbulletins"/>
</web-bnd>
ibm-web-ext.xml:
<web-ext
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<jsp-attribute name="reloadEnabled" value="false"/>
<jsp-attribute name="reloadInterval" value="10"/>
<reload-interval value="3"/>
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="true"/>
</web-ext>
plugin.xml:
<plugin id="com.company.wcm.CompanyWCMPlugins"
name="Company WCM Plugins"
version="1.0.0"
provider-name="Company Name Australia">
<extension
point="com.ibm.workplace.wcm.api.CustomWorkflowActionFactory"
id="CompanyWorkflowActionFactory">
<provider class="com.company.wcm.workflow.CompanyWorkflowActionFactory"/>
</extension>
</plugin>
web.xml:
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
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">
<display-name>CompanyWCM_JSPs</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<resource-ref id="ResourceRef_1377568155870">
<description/>
<res-ref-name>jdbc/wcmbulletins</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
What do I need to make the JNDI lookup work?
What happens if you change the code to bypass the resource reference and use the name jdbc/wcmbulletins instead?
Also - at what scope is the DS defined? If at cluster level try the name cell/persistent/jdbc/wcmbulletins and see what you get.
Lastly - there is always the WebSphere naming trace. You can enable them via Naming=all, re-run your app, and check trace.log for insight as to what might be going on.
Hope this helps,
ScottH
From my experience, wcm plugins are somewhat independent from the web-application they are contained in (they are more related to OSGI or so). For example during server startup plugins are instantiated, before the web-application itself is, so it might not even be possible to reliably lookup resources from the web-app.
We recently switched to Servlet 2.4 and JSP 2 on a project and our custom tags no longer work.
We have tags like:
<myTags:someTag value="${x}" />
and once in the tag we evaluated x bean and went from there. Now the evaluation happens directly in the JSP and we get a String (apparently x.toString()) set for the value attribute.
There are not a lot of tags and I could adapt them in a few days but how can I do that? I could not find anything on the web (or maybe I'm not looking where I should).
How do I pass the x bean to my tag and evaluate it there and not allow it to be evaluated in the JSP?
P.S. I do not want to deactivate the EL-engine
Thank you!
If you redeclare web.xml as Servlet 2.4 as follows
<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/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
and the tld file as JSP 2.0 taglib as follows:
<taglib
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/web-jsptaglibrary_2_0.xsd"
version="2.0">
Then you can add <rtexprvalue>true</rtexprvalue> entries to tag attributes in the TLD file which are expecting EL values. E.g.
<attribute>
<name>value</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
It namely defaults to false.