Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Eu to desenvolvendo um projeto pra faculdade de um dashboard em JSP, mas to tendo um problema com o xml.
abaixo segue os xml's
o primeiro é o xml para conectar a conexao com o banco para gerar o relatorio no ireport
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost/teste</param-value>
</context-param>
<context-param>
<param-name>usuario</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>senha</param-name>
<param-value></param-value>
</context-param>
<context-param>
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<servlet>
<servlet-name>ServletWeb</servlet-name>
<servlet-class>controller.ServletWeb</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletWeb</servlet-name>
<url-pattern>/servletweb</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
o segundo é para cadastrar usuarios para acesso ao sistema em jstl
<?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>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/sql-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/tld/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/x-rt.tld</taglib-location>
</taglib>
</web-app>
eles separados estão funcionando, mas quando eu coloco os 2 juntos no mesmo web.xml, eles dao erro.
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql://localhost/teste</param-value>
</context-param>
<context-param>
<param-name>usuario</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>senha</param-name>
<param-value></param-value>
</context-param>
<context-param>
<param-name>driver</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<servlet>
<servlet-name>ServletWeb</servlet-name>
<servlet-class>controller.ServletWeb</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletWeb</servlet-name>
<url-pattern>/servletweb</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
<web-app>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
<taglib-location>/WEB-INF/tld/sql.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/sql-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
<taglib-location>/WEB-INF/tld/x.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
<taglib-location>/WEB-INF/tld/x-rt.tld</taglib-location>
</taglib>
</web-app>
Description Resource Path Location Type
The markup in the document following the root element must be well-formed. web.xml /PROJETO/WebContent/WEB-INF line 39 XML Problem
o erro é na linha 39 quando abre o segundo <web-app>
alguem sabe solucionar isso?
ou nao é possivel por 2 <web-app> no mesmo xml?
Parece que alguma parte do seu XML está inválida, tente passá-lo no validador do W3C.
sim, @Andre Campos... se especificar como o primeiro (versao, schema) da erro, e um erro diferente.
@mangakah, passei no validador do w3c como você falou, e deu a mesma mensagem do erro que apareceu no eclipse:
Validation Output: 1 Error
Error Line 39, Column 9: document type does not allow element "web-app" here
<web-app>
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).>
sim, @Andre Campos... se especificar como o primeiro (versao, schema) da erro, e um erro diferente.
@mangakah, passei no validador do w3c como você falou, e deu a mesma mensagem do erro que apareceu no eclipse:
Validation Output: 1 Error
Error Line 39, Column 9: document type does not allow element "web-app" here
<web-app>
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
Tente colocar apenas uma tag web-app, movendo o conteúdo da segunda tag web-app para a primeira.
@mangakah, fiz isso que você falou, coloquei em apenas uma tag web-app...
no validador do w3c deu tudo certo.
This document was successfully checked as well-formed XML!
mas no eclipse ele da erro na primeira tag <taglib>
erro:
Description Resource Path Location Type
cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. One of '{"http://java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/j2ee":context-param, "http://java.sun.com/xml/ns/j2ee":filter, "http://java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/ns/j2ee":servlet-mapping, "http://java.sun.com/xml/ns/j2ee":session-config, "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://java.sun.com/xml/ns/j2ee":jsp-config, "http://java.sun.com/xml/ns/j2ee":security-constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/xml/ns/j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://java.sun.com/xml/ns/j2ee":ejb-ref, "http://java.sun.com/xml/ns/j2ee":ejb-local-ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://java.sun.com/xml/ns/j2ee":message-destination-ref, "http://java.sun.com/xml/ns/j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-encoding-mapping-list}' is expected. web.xml /PROJETO/WebContent/WEB-INF line 39 XML Problem
É porque quando juntou tudo o web-app fugiu da formatação sugerida pela documentação.
Não há a possibilidade de trabalhar com os 2 separados como você tinha feito no início?
eles separados funcionam.. mas nao sei como chama-los, porque o ireport e o jstl chama por padrao o WEB-INF/web.xml
se eu pudesse fazer o ireport chamar o web.xml e o jstl chamar o web2.xml.. funcionaria..
mas como eu faço isso?
RESOLVIDO.
Foi só colocar as taglib entre os <jsp-config> que funcionou perfeitamente.
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
.
.
.
</jsp-config>
Especificando o segundo web-app, assim como fez com o primeiro (versão, schema etc), continua dando errado?