Hi,
AM trying to read some values from my web.xml file using the
getInitParamete r method but the application crushes.
here is the web.xml and the servlet:
AM trying to read some values from my web.xml file using the
getInitParamete r method but the application crushes.
here is the web.xml and the servlet:
Code:
public Connection getConnection() {
String url = null;
String username = null;
String password = null;
System.out.println(url);
url = getInitParameter("url");
username = getInitParameter("username");
password = getInitParameter("password");
try {
Class.forName(getInitParameter("jdbc.driver"));
con = (Connection) DriverManager.getConnection(url, username, password);
} catch (Exception e) {
System.out.println("impossible de se connecter a la base de données !");
}
return con;
}
Code:
java.lang.NullPointerException javax.servlet.GenericServlet.getInitParameter(GenericServlet.java:82) com.ayach.tp3.DBConnection.getConnection(DBConnection.java:62) com.ayach.tp3.Formulaire.doGet(Formulaire.java:40) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Comment