JSP+Tomcat學習日記(-) 配置JSP運行環境

Windows 操作系統環境下.

1. 所需軟件:

軟件名稱          安裝包名稱               下載地址
  j2sdk         j2sdk-1_4_2-windows-i586.exe     http://java.sun.com/
  Jakarta-Tomcat    jakarta-tomcat-5.0.28.zip       http://jakarta.apache.org/Apache-Tomcat

2.安裝( 些步驟省略)

3. 配置環境:

我的電腦/屬性/高級/系統環境變量/

classpath  加"E:/j2sdk1.4.2/lib/dt.jar;d:/j2sdk142/lib/tools.jar;d:/j2sdk142/lib;.;" ;($catalina_home%/common/lib/servlet-api.jar;$catalina_home%/common/lib/jsp-api.jar;編譯Java Servlet時所要用到的)  注意後面那個點,它表示當前目錄,包含了該目錄後,就可以到任意目錄下去執行需要用到該目錄下某個類的Java程序;                           

Java_Homa=java所安裝的目錄..

Catalina_home=tomcat 所安裝的目錄..

Path=java所安裝的目錄/bin.

3. 測試: .

http://localhost:8080/出現歡迎界面.. 表示..

 

4以下爲一些具體的錯誤提示及解答:

一.

Exception  message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot allocate servlet instance for path /servlet/myServlet
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:388)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.IllegalAccessException: Class org.apache.catalina.core.StandardWrapper can not access a member of class myServlet with modifiers ""
sun.reflect.Reflection.ensureMemberAccess(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:369)
org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

此時多數情況下, 是因爲你沒有都聲明你的Servlet爲public.

二. 頁面信息如下:

 

 

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

 此是的原因有可能是你的servlet 重載方法了doPost(). 些時將 doPost()改爲doGet()..

正常.

 

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

 此是的原因有可能是你的servlet 重載方法了doPost(). 些時將 doPost()改爲doGet()..

正常.

 

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

 此是的原因有可能是你的servlet 重載方法了doPost(). 些時將 doPost()改爲doGet()..正常.

另一種方法. 由於在你的servlet裏面沒有處理doGet請求啊。
試着在你的servlet文件裏面加入
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{doPost(request,response);}

 

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

 此是的原因有可能是你的servlet 重載方法了doPost(). 些時將 doPost()改爲doGet()..

正常.

發佈了25 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章