Pessoal boa noite, ou bom dia rsrs.
Então eu criei um projeto JSF e criei uma index.jsp, como faço pra chamar essa jsp redirecionando para meu xhtml?
Pessoal boa noite, ou bom dia rsrs.
Então eu criei um projeto JSF e criei uma index.jsp, como faço pra chamar essa jsp redirecionando para meu xhtml?
Assim:
<jsp:forward page="/nomeDaPagina.jsf"/>
Se a sua pagina.xhtml estiver em um diretório diferente da sua index, você deve colocar também o nome do diretório/nomeDaPagina.jsf.
Assim:<jsp:forward page="/nomeDaPagina.jsf"/>Se a sua pagina.xhtml estiver em um diretório diferente da sua index, você deve colocar também o nome do diretório/nomeDaPagina.jsf.
Mas eu coloco essa tag no web.xml?
não, na página index.jsp.
Eu tenho que fazer so isso?
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:forward page="/pages/Cadastro.jsf"/> // aqui a linha que o amigo me passou
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
Aqui o teste que queria subir:
<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<!--
Replace path to template, title, header and body
with actual data.
-->
<ui:composition template="/WebContent/pages/Cadastro.xhtml">
<ui:define name="pageTitle">Title</ui:define>
<ui:define name="pageHeader">Header</ui:define>
<ui:define name="body">
<form jsfc="h:form" id="Form">
<div class = "retangle_top"/>
<h: inputText id = "#{textNome} value = "Nada" />
</form>
</ui:define>
</ui:composition>
</html>
Na index.jsp, coloque apenas isso.
<jsp:forward page="/pages/Cadastro.jsf"/>
O erro é de página não encontrada. Se suas páginas são .jsf, de ser Cadastro.jsf.
Minhas paginas sao xhtml.
Se você fosse digitar a url no browser, como você escreveria?
cadastro.xhtml?
Se você fosse digitar a url no browser, como você escreveria?
cadastro.xhtml?
omg rs, .jsf. Mas eu coloquei jsf no redirecionamento.
Mas na imagem que você postou está com Cadastro.jsp.
Eu tenho uma index.jsp que contém a linha: <jsp:forward page="/pages/Cadastro.jsf"/>
e minha pagina Cadastro é xhtml, mas coloquei jsf para o redirecionamento.
Estranho. Colocando apenas aquela linha na sua index.jsp, era para funcionar. Tem alguma estrutura de diretórios para as páginas?
Estranho. Colocando apenas aquela linha na sua index.jsp, era para funcionar. Tem alguma estrutura de diretórios para as páginas?
Minha pagina Cadastro.xhtml esta na seguinte estrutura: Everton\WebContent\pages\Cadastro.xhtml
Agora uma pergunta, precisa configurar algum arquivo, como web-xml ou faces config pra funcionar isso?
Nada demais.
web.xml.
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
E a sua index.jsp deve ter apenas essa linha:
<jsp:forward page="/pages/Cadastro.jsf"/>
eh =/ então ta tenso, ja nao sei mais o que fazer.
O web.xml ta assim:
<?xml version="1.0"?>
<web-app 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>TesteWeb</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- 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>*.jsf</url-pattern>
</servlet-mapping>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>
</web-app>
E como ta sua index? Ele ta chamando essa index?
A index ta igual vc falou:
<jsp:forward page="/pages/Cadastro.jsf"/>
A página index está sendo chamada? Coloca um código qualquer para ver se ela é executada.
Ta sim coloquei um breakpoint e subi o JBoss no debug ele entrou la 
verifica no seu web.xml se a sua extensão reconhecida para faces é .jsf mesmo:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
verifica no seu web.xml se o default suffix está para .xhtml mesmo, ou para .jsp (qualquer coisa posta ele aqui para vermos)
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
Outra coisa, se você quiser fazer o tomcat ler para “server:8080/seuprojeto/” algum arquivo específico, é só você alterar, no web.xml, o parâmetro welcome-file-list
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
Opa evufuji nao tinha essas configuraçoes nao, coloquei mas nao funcionou, vou colocar aqui o web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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" version="2.5">
<display-name>Everton</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
minha index index.jsp
<jsp:forward page="/pages/Cadastro.jsf"/>
minha Pagina cadastro que eu queria subir:
<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<!--
Replace path to template, title, header and body
with actual data.
-->
<ui:composition template="">
<ui:define name="pageTitle">Title</ui:define>
<ui:define name="pageHeader">Header</ui:define>
<ui:define name="body">
<form jsfc="h:form" id="Form">
<div class = "retangle_top"/>
<h: inputText id = "#{textNome} value = "Nada" />
</form>
</ui:define>
</ui:composition>
</html>
Em algum lugar você troca o mime type que o server informa ao navegador? Tipo, no seu template tem alguma metatag que fale o formato, algo como isso.
http-equiv="Content-Type" content="text/html; charset=utf-8" />
ou mesmo em algum bean seu.
Eu tirei o “<” do inicio, mas continuo do mesmo jeito, sobre o mime type não sei o que é =[
Em algum lugar você troca o mime type que o server informa ao navegador? Tipo, no seu template tem alguma metatag que fale o formato, algo como isso.http-equiv="Content-Type" content="text/html; charset=utf-8" />ou mesmo em algum bean seu.
nao tem nao
então defina no seu web.xml os mime types para cada extensão de arquivo:
<!-- MIME mapping -->
<mime-mapping>
<extension>doc</extension>
<mime-type>application/vnd.ms-word</mime-type>
</mime-mapping>
<mime-mapping>
<extension>dsp</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>gif</extension>
<mime-type>image/gif</mime-type>
</mime-mapping>
<mime-mapping>
<extension>htm</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>html</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jnlp</extension>
<mime-type>application/x-java-jnlp-file</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpeg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>jpg</extension>
<mime-type>image/jpeg</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>application/x-javascript</mime-type>
</mime-mapping>
<mime-mapping>
<extension>pdf</extension>
<mime-type>application/pdf</mime-type>
</mime-mapping>
coloquei todos, mas ta abrindo a pg pra fazer dl =[
ta gerando no console ao final:
Buildfile: C:\Users\everton\Desktop\eclipse-jee-helios-SR1-win32-x86_64\eclipse\plugins\org.eclipse.jst.server.generic.jboss_1.6.1.v200904151730\buildfiles\jboss323.xml
deploy.j2ee.web:
[jar] Building jar: C:\Users\everton\Documents\web\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\Everton.war
[move] Moving 1 file to C:\Program Files\jboss-5.0.0.CR2-jdk6\jboss-5.0.0.CR2\server\default\deploy
BUILD SUCCESSFUL
Total time: 10 seconds
Ta gerando o deploy normal
Olá.
Lembro de ter passado por esse erro,mas não consegui simular aqui
esse é meu web.xml q funciona:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<display-name>projetoBase</display-name>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<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>
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
Mas como vou adaptar seu web.xml com o meu??
por exemplo, esse extension filter aqui esta dando erro na hora do deploy.
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
se eu tiro ele fica a pagina pra dl
Vai vendo o que se adapta ou não 
Everton,
Voce conseguiu pegar essa pagina jsp ?
Também estou precisando fazer isso.
Obrigado;
Consegui nao amigo =[, negocio ta feio kkk. Quando digito no browser http://localhost:8080/Everton, abre um dialog pra dl =[
Puts,
Beleza então, eu também estouy tentando aqui, qualquer coisa eu posto para nós =)
Abs
Everton,tu está usando RichFaces?
tem alguma linha mais ou menos assim response.setContentType(“text/html”); em algum constructor do seu bean?
Tenta colocar um metatag no seu template que defina o content type para text/html.
to não rafa.
evefuji eu nem tenho nenhum bean ainda so tenho essa pagina.
to não rafa.
evefuji eu nem tenho nenhum bean ainda so tenho essa pagina.
me mostra as libs do teu projeto.
common-annotations
commons-beanutils
commons-collections
commons-digester
commons-logging
jsf-tlds
jstl
standard
tá faltando libs aí, a do jsf-api, jsf-impl, facelets (não lembro se falta mais alguma)
ueh, eu fui dentro de web-inf\lib é tudo que ta la.
exatamente,tem coisa faltando ai.
mas como vou colocar algo? Se eu só criei o projeto e nao adicionei lib nem removi lib nenhuma.
baixa aqui os JAR’s: https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=10411 e pega tudo que estiver dentro da pasta lib do que vc baixou e coloca no lib do seu projeto. (a menos que você tenha o jsf-impl e o jsf-api no lib do seu tomcat, que isso não é necessário)
Mas esses jar’s deveriam causar outro erro, não o de informar o mime type errado ao server né? Você está usando Tomcat mesmo certo? (Glassfish já vem com as libs de jsf)
Edit: também existe o web.xml do seu tomcat, que informa os mime type padrão para cada extensão de arquivo. Dá uma olhada nele.
Eu estou usando JBoss
não lembro se o JBoss já tem nele as libs do jsf, tem que verificar.
Mas vc declarou os mime types no web.xml como eu disse anteriormente (eu dei exemplo, não listei todos os mime types para vc colocar lá)
Conseguiu resolver o problema?
Coloque a seguinte instrução no seu arquivo web.xml:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>