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()..

正常.

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页