innanzitutto grazie a tutti dell'attenzione....
il momento stà diventando catartico!!!!
iniziamo subito come non si dovrebbe iniziare... ALLORA...
stò instalando sul mio PC tutto il necessario per creare pagine JSP e connettermi ad un DB di tipo MySQL quindi...
1) SDK e JRE (bla bla bla) installati da sempre!
2) TOMCAT 5.59 Installato correttamente (vedo tutti gli esempi e via dicendo)
3) MySQL installato correttamente (mi connetto e creo database a rotella quindi tutto OK)
4) Connector-J scaricato!
ORA...quello che voglio fare è una semplice pagina JSP che si connetta ad un DB MySQL e mi faccia vedere i dati...
per fare questo ho copiato pari pari quello che si diceva sul sito della TOMCAT all'indirizzo
http://jakarta.apache.org/tomcat/tom...les-howto.html
1) ho messo il file mysql-connector-java-3.1.10-bin.jar all'interno della cartella common/lib della root del TOMCAT
2) ho modificato il file server.xml aggiungendo
subito prima della chiusura del tab </Host> nel file server.xml della cartella conf della root del TOMCATcodice:<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log." suffix=".txt" timestamp="true"/> <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/TestDB"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <!-- Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. --> <parameter> <name>maxActive</name> <value>100</value> </parameter> <!-- Maximum number of idle dB connections to retain in pool. Set to -1 for no limit. See also the DBCP documentation on this and the minEvictableIdleTimeMillis configuration parameter. --> <parameter> <name>maxIdle</name> <value>30</value> </parameter> <!-- Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. --> <parameter> <name>maxWait</name> <value>10000</value> </parameter> <parameter> <name>username</name> <value>javauser</value> </parameter> <parameter> <name>password</name> <value>javadude</value> </parameter> <!-- Class name for the old mm.mysql JDBC driver - uncomment this entry and comment next if you want to use this driver - we recommend using Connector/J though <parameter> <name>driverClassName</name> <value>org.gjt.mm.mysql.Driver</value> </parameter> --> <parameter> <name>driverClassName</name> <value>com.mysql.jdbc.Driver</value> </parameter> <!-- The JDBC connection url for connecting to your MySQL dB. The autoReconnect=true argument to the url makes sure that the mm.mysql JDBC Driver will automatically reconnect if mysqld closed the connection. mysqld by default closes idle connections after 8 hours. --> <parameter> <name>url</name> <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value> </parameter> </ResourceParams> </Context>
3) mi sono creato una cartella dal nome DBTest sotto webapps della root del TOMCAT
4) all'interno della cartella DBTest ci ho creato un'altra cartella chiamata WEB-INF
5) all'interno della cartella WEB-INF ci ho messo un file web.xml con questo contenuto
all'interno della cartella DBTest invece ci ho messo un file chiamato test.jsp contenente questocodice:<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"> <description>MySQL Test App</description> <resource-ref> <description>DB Connection</description> <res-ref-name>jdbc/TestDB</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> </web-app>
ed infine ho testato il tutto all'indirizzo: http://localhost:8080/DBTest/test.jspcodice:<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <sql:query var="rs" dataSource="jdbc/TestDB"> select id, foo, bar from testdata </sql:query> <html> <head> <title>DB Test</title> </head> <body> <h2>Results</h2> <c:forEach var="row" items="${rs.rows}"> Foo ${row.foo} Bar ${row.bar} </c:forEach> </body> </html>
ma mi da questo maledettissimo errore:
più naturalmente tutto lo stack errorato...codice:org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/sql cannot be resolved in either web.xml or the jar files deployed with this application
ora a me sembra di aver fatto tutto quello che mi è stato detto ma posso essermi sbagliato...
l'unica cosa che non sono sicuro è se ho fatto bene a modificare il file server.xml e se si se l'ho modificato nei punti giusti, oppure se il connettore andava rinominato...
non lo so ma sono 2 giorni che mi ingegno e credo di esserci quasi riuscito...se mi date una mano sono sicuro che ci riesco a far funzionare quella dannata pagina...
per uno che conosce il TOMCAT ci vuole 5 minuti a fare quello che c'è scritto...
vi ringrazio moltissimo dell'aiuto, ciao![]()
![]()
![]()

Rispondi quotando