Hallo ...
habe noch ein Problem bei der Erstellung von Servlet in Tomcat bei der web.xml Datei...
...so hab noch mal mein Pfad eingeschrieben
+ angela2|
- database ...Datenbank
- graphics....Dateien ...Bilder und .html Dateien
+ WEB-INF
|
+ classes ...alle Java Dateien mit .class
- web.xml
unter http://127.0.0.1:8080/angela2/ aufrufen
zb: eine Showall.java Datei dazu:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Showall extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
java.util.Properties props = new java.util.Properties();
props.put("user", " ");
props.put("password", " ");
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String connectionURL = "jdbcdbc:angela2";
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Programmierung III</title>");
out.println("<link REL='stylesheet' TYPE='text/css' HREF='../../style.css' TITLE='formal'>");
out.println("</head>");
out.println("<body bgcolor='aliceblue' topmargin='0' leftmargin='0'>");
buildtabledel(driverName,connectionURL,props,out);
out.println("</body>");
out.println("</html>");
}
void buildtabledel(String driverName,String connectionURL, java.util.Properties props, PrintWriter out)
{
out.println("<form name='frm4' method='get' action='showallresp'>");
out.println("<table border=0>");
out.println("<tr>");
out.println("<td bgcolor='yellow' height='30'><font color='blue'>&LISTING ALL RECORDS MODULE</font>&&&&&");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td bgcolor='WHITE'>");
listregid(driverName,connectionURL,props,out);
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</form>");
}
void listregid(String driverName,String connectionURL, java.util.Properties props, PrintWriter out)
{
String query = "SELECT * FROM student_det";
boolean rc = true;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
int rowCount = 0;
out.println("<center><table border='1' bordercolor='#000000' style='border: Black;'>");
try
{
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(connectionURL, props);
stmt = con.createStatement();
rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
String tempval="";
int columnCount = rsmd.getColumnCount();
out.println("<tr bgcolor='gray'>");
for (int i = 1; i <= 3; i++)
{
out.println("<td><font color='white'>" + rsmd.getColumnLabel(i + 1) + "</font></td>");
}
out.println("</tr>");
while (rs.next())
{
out.println("<tr>");
for (int i = 1; i <= 3; i++)
{
if(i==1)
{
tempval=rs.getString(i+1);
out.println("<td><font color='black'>"+tempval+"</font></td>");
}
else
{
out.println("<td><font color='black'>"+rs.getString(i+1)+"</font></td>");
}
}
out.println("</tr>");
}
out.println("</table></center>");
}
catch (Exception ex)
{
out.println("Exception!");
ex.printStackTrace(out);
rc = false;
}
finally
{
try
{
if (rs != null)
{
rs.close();
}
if (stmt != null)
{
stmt.close();
}
if (con != null)
{
con.close();
}
}
catch (Exception ex)
{
// Do Nothing here
}
}
}
}
web.xml :
<!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>
<!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>angela2</display-name>
<servlet>
<servlet-name>Addrec</servlet-name>
<servlet-class>Addrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Addrec </servlet-name>
<url-pattern>/Addrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Addrecresp</servlet-name>
<servlet-class>Addrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Addrecresp</servlet-name>
<url-pattern>/Addrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Delrec</servlet-name>
<servlet-class>Delrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Delrec</servlet-name>
<url-pattern>/Delrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Delrecresp</servlet-name>
<servlet-class>Delrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Delrecresp</servlet-name>
<url-pattern>/Delrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrec</servlet-name>
<servlet-class>Modrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrec</servlet-name>
<url-pattern>/Modrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrecresp2</servlet-name>
<servlet-class>Modrecresp2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrecresp2</servlet-name>
<url-pattern>/Modrecresp2</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrecresp</servlet-name>
<servlet-class>Modrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrecresp</servlet-name>
<url-pattern>/Modrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Showall</servlet-name> ... .java Datei
<servlet-class>Showall</servlet-class> ... .class Datei ....benutze aber kein Package
Was muß da genau denn da hin ??????????????????
</servlet>
<servlet-mapping>
<servlet-name>Showall</servlet-name> ... .java Datei
<url-pattern>/Showall</url-pattern> ....URL
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Folgende Fehlermeldung bekomme ich:
HTTP Status 404 - /WEB-INF/classes/Showall
type Status report
message /WEB-INF/classes/Showall
description The requested resource (/WEB-INF/classes/Showall) is not available
Woran kann das liegen...oder...Was mach ich da falsch?????
Bitte um Hilfe...Verzweifle bald....(((( Vielen Dank!!! )))
Angela
habe noch ein Problem bei der Erstellung von Servlet in Tomcat bei der web.xml Datei...
...so hab noch mal mein Pfad eingeschrieben
+ angela2|
- database ...Datenbank
- graphics....Dateien ...Bilder und .html Dateien
+ WEB-INF
|
+ classes ...alle Java Dateien mit .class
- web.xml
unter http://127.0.0.1:8080/angela2/ aufrufen
zb: eine Showall.java Datei dazu:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class Showall extends HttpServlet
{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
java.util.Properties props = new java.util.Properties();
props.put("user", " ");
props.put("password", " ");
String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
String connectionURL = "jdbcdbc:angela2";
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Programmierung III</title>");
out.println("<link REL='stylesheet' TYPE='text/css' HREF='../../style.css' TITLE='formal'>");
out.println("</head>");
out.println("<body bgcolor='aliceblue' topmargin='0' leftmargin='0'>");
buildtabledel(driverName,connectionURL,props,out);
out.println("</body>");
out.println("</html>");
}
void buildtabledel(String driverName,String connectionURL, java.util.Properties props, PrintWriter out)
{
out.println("<form name='frm4' method='get' action='showallresp'>");
out.println("<table border=0>");
out.println("<tr>");
out.println("<td bgcolor='yellow' height='30'><font color='blue'>&LISTING ALL RECORDS MODULE</font>&&&&&");
out.println("</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td bgcolor='WHITE'>");
listregid(driverName,connectionURL,props,out);
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</form>");
}
void listregid(String driverName,String connectionURL, java.util.Properties props, PrintWriter out)
{
String query = "SELECT * FROM student_det";
boolean rc = true;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
int rowCount = 0;
out.println("<center><table border='1' bordercolor='#000000' style='border: Black;'>");
try
{
Class.forName(driverName).newInstance();
con = DriverManager.getConnection(connectionURL, props);
stmt = con.createStatement();
rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
String tempval="";
int columnCount = rsmd.getColumnCount();
out.println("<tr bgcolor='gray'>");
for (int i = 1; i <= 3; i++)
{
out.println("<td><font color='white'>" + rsmd.getColumnLabel(i + 1) + "</font></td>");
}
out.println("</tr>");
while (rs.next())
{
out.println("<tr>");
for (int i = 1; i <= 3; i++)
{
if(i==1)
{
tempval=rs.getString(i+1);
out.println("<td><font color='black'>"+tempval+"</font></td>");
}
else
{
out.println("<td><font color='black'>"+rs.getString(i+1)+"</font></td>");
}
}
out.println("</tr>");
}
out.println("</table></center>");
}
catch (Exception ex)
{
out.println("Exception!");
ex.printStackTrace(out);
rc = false;
}
finally
{
try
{
if (rs != null)
{
rs.close();
}
if (stmt != null)
{
stmt.close();
}
if (con != null)
{
con.close();
}
}
catch (Exception ex)
{
// Do Nothing here
}
}
}
}
web.xml :
<!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>
<!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>angela2</display-name>
<servlet>
<servlet-name>Addrec</servlet-name>
<servlet-class>Addrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Addrec </servlet-name>
<url-pattern>/Addrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Addrecresp</servlet-name>
<servlet-class>Addrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Addrecresp</servlet-name>
<url-pattern>/Addrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Delrec</servlet-name>
<servlet-class>Delrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Delrec</servlet-name>
<url-pattern>/Delrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Delrecresp</servlet-name>
<servlet-class>Delrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Delrecresp</servlet-name>
<url-pattern>/Delrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrec</servlet-name>
<servlet-class>Modrec</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrec</servlet-name>
<url-pattern>/Modrec</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrecresp2</servlet-name>
<servlet-class>Modrecresp2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrecresp2</servlet-name>
<url-pattern>/Modrecresp2</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Modrecresp</servlet-name>
<servlet-class>Modrecresp</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Modrecresp</servlet-name>
<url-pattern>/Modrecresp</url-pattern>
</servlet-mapping>
<display-name>angela2</display-name>
<servlet>
<servlet-name>Showall</servlet-name> ... .java Datei
<servlet-class>Showall</servlet-class> ... .class Datei ....benutze aber kein Package
Was muß da genau denn da hin ??????????????????
</servlet>
<servlet-mapping>
<servlet-name>Showall</servlet-name> ... .java Datei
<url-pattern>/Showall</url-pattern> ....URL
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
Folgende Fehlermeldung bekomme ich:
HTTP Status 404 - /WEB-INF/classes/Showall
type Status report
message /WEB-INF/classes/Showall
description The requested resource (/WEB-INF/classes/Showall) is not available
Woran kann das liegen...oder...Was mach ich da falsch?????
Bitte um Hilfe...Verzweifle bald....(((( Vielen Dank!!! )))
Angela