Hi!
there is a deployment-guide for this
(Tomcat5 is j2ee1.4-compatible, means supporting JSP2.0)
http://java.sun.com/j2ee/javaserverfaces/docs/Deployment_Guide.html
Taglib-distr. you got @jakarta-taglibs-projekt (Standard-1.1: JSTL 1.1 (JSP2.0))
Cheers,
Matthias
Hi Thomas!
i deploy my WARs in /web-app
inside of every war there is a folder WEB-INF/lib.
the needed jars i place them here.
did got errors on deploying sample-wars of JSF_1.0_Final ?
e.g. cardemo? (in folder jsf-1_0/samples)
cheers,
Matthias
btw.
in begin of june (installation is covered ;-))
Hi Matthias,
so, i only have to put the JSF-jars
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
into the lib-directory?
And this into the tlds-directory?
html_basic.tld
jsf_core.tld
What about this file shipped with JSF?
web-facesconfig_1_0.dtd
Bestr regards
Thomas
Hi Thomas,
here is a sample structure of a jsf-app:
WEB-INF/classes
your class-files
WEB-INF/
web.xml
faces-config.xml
WEB-INF/lib:
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
jstl.jar
standard.jar
the tlds are placed in jsf-impl.jar
but i place them in WEB-INF
the dtd is for writing faces-config
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
...
</faces-config>
with XML-Editor (xmlSpy) you are able to check validness of your faces-config.xml-file
hope that helps
Cheers
matthias
Hi Matthias,
it doesn't work.
I did it analog to yor posting and now Tomcat threw this exception while
calling my app.
java.lang.NullPointerException
javax.faces.webapp.FacesServlet.init(FacesServlet.java:144)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
java.lang.Thread.run(Thread.java:534)
Please: Any suggestions?
Best regards
Thomas
hi
did you define a mapping?
web.xml
<!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>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
so enter http://localhost:8080/myFirstJSFApp/myFirstPage.faces
(your page, containing components is the page myFirstPage.jsp)
with ending .faces (or .thomas (like you like)) JSF-Servlets renders your components
<h:outputText value="Hallo Thomas!"/>
but must contained in <f:view> <h:../></f:view>
like this:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
</head>
<f:view>
<h:outputText value="Hallo Thomas"/>
</f:view>
</html>
[nobr]Hi Matthias,
Sorry about my boring posts, but i think i must post everything:
It's a app called squarecalc:
Ok, first the web.xml:
<?xml version="1.0"?>
<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 web-app_2_4.xsd"
version="2.4">
<!-- ############# Faces Servlet ############# -->
<servlet>
<servlet-name>JavaServer Faces Servlet</servlet-name>
<servlet-class>
javax.faces.webapp.FacesServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- ############# Mapping ############### -->
<servlet-mapping>
<servlet-name>JavaServer Faces Servlet</servlet-name>
<url-pattern>/faces/*.jsf</url-pattern>
</servlet-mapping>
</web-app>
The faces-config.xml:
<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<navigation-rule>
<from-view-id>/faces/eingabe.jsf</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/faces/ausgabe.jsf</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>Square</managed-bean-name>
<managed-bean-class>com.edu.jsf.bean.SquareBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
The eingabe.jsf:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>Berechnung eines Flcheninhaltes</title>
</head>
<body>
<f:view>
<h3>JSF-Beispielanwendung zur Berechnung eines Fl cheninhaltes:</h3>
<i>Dieses Programm berechnet aufgrund der Eingabe einer
Seitenlnge den Fl cheninhalt eines Quadrates.</i>
<br><br>
<h:form id="inputForm">
Bitte geben Sie eine Seitenlnge ein:
<h:inputText value="#{Square.length}" />
<h:commandButton value="Berechnen" action="success" />
</h:form>
</f:view>
</body>
</html>
The ausgabe.jsf:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>Berechnung eines Flcheninhaltes</title>
</head>
<body>
<f:view>
<h3>JSF-Beispielanwendung zur Berechnung eines Fl cheninhaltes:</h3>
<i>Dieses Programm berechnet aufgrund der Eingabe einer
Seitenlnge den Fl cheninhalt eines Quadrates.</i>
<br><br>
<h:form id="inputForm">
Ergebnis der Berechnung<br><br>
Ihre Eingabe war: <h:outputText value="#{Square.length}" />
<br>
damit ist der Flcheninhalt: <h:outputText value="#{Square.area}" />
</h:form>
</f:view>
</body>
</html>
The SquareCalc.java:
package com.edu.jsf.bean;
public class SquareBean {
private int length;
private int area;
public int getArea() {
return length*length;
}
public int getLength() {
return length;
}
public void setArea(int i) {
area = i;
}
public void setLength(int i) {
length = i;
}
}
The directory-structure:
tomcat-root
-webapps
--squarecalc
faces
-ausgabe.jsf
-eingabe.jsf
WEB-INF
-classes
-lib
-tlds
In classes is of course the SquareClalc-Bean.
In lib is:
commons-beanutils.jar
commons-collections.jar
commons-digester.jar
commons-logging.jar
jsf-api.jar
jsf-impl.jar
In tlds is:
html_basic.tld
jsf_core.tld
Sorry for the long and boring posting.
Best regards & thanks
Thomas[/nobr]
Hi Thomas,
Default Ending of pages is .jsp
nename your files so
btw you can change it by:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>*.thomas</param-value>
</context-param>
:-)
but i use default *.jsp
you use
<url-pattern>/faces/*.jsf</url-pattern>
/faces/* is from former specs
use *.jsf instead
<url-pattern>*.jsf</url-pattern>
or *.faces (better)
place ausgabe.jsp NOT jsf
in squarecalc/
and not in squarecalc/faces
(and of course eingabe.jsP)
then call http://localhost:8080/squarecalc/ausgabe.jsf
(JSF) like mapping...
any probs? :)
matthias AT wessendorf DOT net
:-)
Hi Matthias,
there is no end....
I had some problems with the JSTL(?)
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:135)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
Why, i thought it's (JSTL1.2) shipped with Tomcat 5?
Best regards (i will buy your book - shure!)
Thomas
Hi Thomas
you must also add the jars for JSTL1.2
in WEB-INF/lib
jstl.jar
standard.jar
they are hosted @jakarta_taglibs_project
or you could use them, that are inside of a WAR
that was delivered in JSF_1.0_samples
(unpack it --> WEB-INF/lib/)
no prob!
every beginning is hard... :-)
Cheers!
Hi Matthias,
unfortunately it's not working now.
I have no exceptions, doing a request to eingabe.jsp
the machine hangs up. The CPU goes up to 100% and
the Browser gets no response.
Theres nothing in the logs.
BTW:
I don't deploy it via war i build a directory directly under
webapps.
Best regards
Thomas
Hi Matthias once more,
it seems there is something wrong i must discover by my one.
I downloaded the jsf-samples and voila they work fine.
So there is some "voodoo" in my example.
I try to setup my example completely new, perhaps i
find the error. I think it's hidden on the circumstnce,
that i have some docs about the beta of jsf.
To you my best thanks. Sorry, that i had stolen your time.
If i find the cause of this mess, i will post it.
Thanks & best regards
Thomas
the problem here was wrong mapping (he mailed me his app)
you have to have a file with suffix *.jsp, that contains your components.
in web.xml you must define a mapping for your "servlet" (on which requests it will react)
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<!-- JavaServer Faces Servlet Configuration -->
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup>
</servlet>
<!-- JavaServer Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
if you now want to access your "foo.jsp", that contains your components, you have to enter
the following url:
http:/localhost:8080/nameOfMyApp/foo.faces
and page should be displayed...
that was the error of thomas.
so perhaps it helps you , too
cheers. matthias