為什麼我的servlet在weblogic6.1中跑不起來?

framework發表於2003-06-01
我用jcreator寫的一個hello world的servlet但是不能執行
在url輸入http://localhost:7001/DefaultWebApp/MyHelloWorld時出現

Error 500--Internal Server Error
From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
10.5.1 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the

request

的錯誤提示,我在jcreator中的jdk的設定為d:\bea\jdk131,我包含了weblogic_sp.jar和
weblogic.jar兩個包編譯成.class。
不知道我錯在什麼地方,請高手們相助,下面是配置檔案和原始碼

我的配置檔案
web.xml:
<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 1.2//EN"

"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HelloWorld2</servlet-name>
<servlet-class>examples.servlets.HelloWorld2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld2</servlet-name>
<url-pattern>/HelloWorld2</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>MyHelloWorld</servlet-name>
<servlet-class>examples.servlets.MyHelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyHelloWorld</servlet-name>
<url-pattern>/MyHelloWorld</url-pattern>
</servlet-mapping>
</web-app>

MyHelloWorld.java內容:

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;



public class MyHelloWorld extends HttpServlet{
private int counter=0;	
	public MyHelloWorld(){
		super();
		System.out.println("My Hello world example");
	}
	
	public void init() throws ServletException{
		System.out.println("My Hello world init");
	}
	
	public void service(HttpServletRequest request, HttpServletResponse response)
	throws IOException{
		counter++;
		String userName = request.getParameter("username");
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<html>");
		out.println("<head><title>My Hello World</title></head>");
		out.println("<body>");
		out.println("<p>Hello ,"+ userName + "!</p>");
		out.println("This servlet has been invoked"+ counter + " times");
		out.println("</body></html>");
		System.out.println("HelloServlet.doGet() invoked");
	}
	
	public void destroy(){
		System.out.println("My Hello world destroyed");
	}
	
}

相關文章