|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Feb 2002
Città: Portici
Messaggi: 92
|
Problemi con il file "WEB.XML" di Tomcat 5.0
C'é un modo per evitare di replicare (per ogni Servlet inserito in Tomcat 5.0) le seguenti linee di codice?
<servlet> <servlet-name>Ricerca</servlet-name> <servlet-class>Ricerca</servlet-class> </servlet> <servlet-mapping> <servlet-name>Ricerca</servlet-name> <url-pattern>/servlet/Ricerca</url-pattern> </servlet-mapping> |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jan 2001
Città: Milano
Messaggi: 5707
|
Che io sappia no, quei mapping sono fondamentali.
Qualsiasi ide e' pero' in grado di generare un web.xml coi mapping di default corretti. Ma ne hai così tante ? |
|
|
|
|
|
#3 |
|
Member
Iscritto dal: Feb 2002
Città: Portici
Messaggi: 92
|
C'é un modo diverso per scrivere il file web.xml in modo, che aprescindere da quanti e da come si chiamano i servlet, mi permetta di utilizzarli senza problemi e senza dover replicare per ogni servlet un determinato blocco di codice?
Mi ricordo che con la versione 4 di Tomcat, questo problema non lo avevo, mi bastava inserire i servlet senza dover fare alcuna modifica al file web.xml. Dove posso scaricare un manuale di xml in modalità free? |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Dec 2001
Città: Roma
Messaggi: 542
|
L'anno scorso per un esame avevo fatto un progetto con tomcat e servlet, ed in effetti non ho dovuto fare tutto quel lavoro per ogni servlet. Il file web.xml era semplicemente così:
Codice:
<?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> <servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> </web-app> Non so se ci sono svantaggi nel fare in questo modo, però mi ricordo che in quel progetto c'erano circa 25 servlet quindi sarebbe stata una botta scrivere la dichiarazione e il mapping per ognuna...vabbè che copia-incolla rulez però è molto più sbrigativo così. NOTA: questa cosa l'ho fatta con Tomcat 4.1, ma presumo che vada anche col 5.
__________________
Il 90% dei problemi di un computer si trova tra la tastiera e la sedia. XP2500+@3200+|A7N8X Deluxe|1,25 GB DDR400|Radeon 9550|HD 160+320 GB SATA|WinXP Pro|Fastweb 6 Mb/s |
|
|
|
|
|
#5 |
|
Member
Iscritto dal: Feb 2002
Città: Portici
Messaggi: 92
|
Ho provato con questo file web.xml, però la risposta di tomcat é stata:
HTTP Status 503 - This application is not currently available -------------------------------------------------------------------------------- type Status report message This application is not currently available description The requested service (This application is not currently available) is not currently available. -------------------------------------------------------------------------------- Apache Tomcat/5.0.19 Cosa mi posso inventare? |
|
|
|
|
|
#6 |
|
Member
Iscritto dal: Feb 2002
Città: Portici
Messaggi: 92
|
Il codice del mio file web.xml é:
<?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> <display-name>Servlet Personale</display-name> <description> Servlet 2.4 Examples. </description> <!-- Define servlet-mapped and path-mapped example filters --> <filter> <filter-name>Servlet Mapped Filter</filter-name> <filter-class>filters.ExampleFilter</filter-class> <init-param> <param-name>attribute</param-name> <param-value>filters.ExampleFilter.SERVLET_MAPPED</param-value> </init-param> </filter> <filter> <filter-name>Path Mapped Filter</filter-name> <filter-class>filters.ExampleFilter</filter-class> <init-param> <param-name>attribute</param-name> <param-value>filters.ExampleFilter.PATH_MAPPED</param-value> </init-param> </filter> <!-- Define servlets that are included in the example application --> <servlet> <servlet-name>Inserisci</servlet-name> <servlet-class>Inserisci</servlet-class> </servlet> <servlet-mapping> <servlet-name>Inserisci</servlet-name> <url-pattern>/servlet/Inserisci</url-pattern> </servlet-mapping> <servlet> <servlet-name>Modifica</servlet-name> <servlet-class>Modifica</servlet-class> </servlet> <servlet-mapping> <servlet-name>Modifica</servlet-name> <url-pattern>/servlet/Modifica</url-pattern> </servlet-mapping> <servlet> <servlet-name>Ricerca</servlet-name> <servlet-class>Ricerca</servlet-class> </servlet> <servlet-mapping> <servlet-name>Ricerca</servlet-name> <url-pattern>/servlet/Ricerca</url-pattern> </servlet-mapping> <security-constraint> <display-name>Example Security Constraint</display-name> <web-resource-collection> <web-resource-name>Protected Area</web-resource-name> <!-- Define the context-relative URL(s) to be protected --> <url-pattern>/jsp/security/protected/*</url-pattern> <!-- If you list http methods, only those methods are protected --> <http-method>DELETE</http-method> <http-method>GET</http-method> <http-method>POST</http-method> <http-method>PUT</http-method> </web-resource-collection> <auth-constraint> <!-- Anyone with one of the listed roles may access this area --> <role-name>tomcat</role-name> <role-name>role1</role-name> </auth-constraint> </security-constraint> </web-app> Come posso fare per risolvere il mio problema? |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 04:15.


















