我的Tomcat4.1怎么了????(50分)

  • 主题发起人 主题发起人 刘忠平
  • 开始时间 开始时间

刘忠平

Unregistered / Unconfirmed
GUEST, unregistred user!
兄弟刚用jsp做servlet但我的indexservelt用不起来?
错误如下:
HTTP Status 404 - /servlet/indexServlet
--------------------------------------------------------------------------------
type Status report
message /servlet/indexServlet
description The requested resource (/servlet/indexServlet) is not available.

--------------------------------------------------------------------------------
Apache Tomcat/4.1

请各位高手次教
 
你是没有启动tomcat,你可以tomcat start
 
你那个资源是不可以用的,试用ShellExecute激活计算机上的浏览器并连倒它。
不行的话,就试试SHLGZ的方法
 
没有放对地方
 
是这样的,我的tomcat肯定起来了,
我自己的目录是D:/TestJava/webtest
JSP在此目录下
servlet class文件在 D:/TestJava/webtest/WEB-INF/classes下
全都在JB6下执行通过
 
在WEB_INF下的web.xml文件中。加入以下代码试试
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
另能否帮俺看看http://www.delphibbs.com/delphibbs/dispq.asp?lid=1700936
 
大家看看是不是这句用问题:
<% response.sendRedirect("servlet/indexServlet");
%>
 
在你的appdir/WEB-INF/classes下放入一testservlet.class
能正常访问http://youserver/appdir/servlet/testservlet吗?
 
放上出以下错误,我要倒了
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
 
各位大哥,麻烦问一下,什么是Tomcat呀?呵呵“汤姆的猫”
 
tomcat是中间件吧,支持多种操作平台的
 
各位大虾,帮忙看看

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

/**
* <p>Title: 这是一个testjava 的程序</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: JS</p>
* @author jimliu
* @version 1.0
*/
public class indexServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;
charset=GB2312";
//Initialize global variables
public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
String cmd=req.getParameter("cmd");
if(cmd==null)
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals(""))
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("login"))
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("logout"))
{
resp.sendRedirect("../logout.jsp");
}
if(cmd.equals("cart"))
{
resp.sendRedirect("../cart.jsp");
}
if(cmd.equals("clear"))
{
resp.sendRedirect("../clear.jsp");
}
if(cmd.equals("order"))
{
resp.sendRedirect("../order.jsp");
}
if(cmd.equals("main"))
{
resp.sendRedirect("../main.jsp");
}
if(cmd.equals("list"))
{
resp.sendRedirect("../list.jsp");
}
if(cmd.equals("remove"))
{
String id=req.getParameter("id");
resp.sendRedirect("../remove.jsp?id="+id);
}
if(cmd.equals("init"))
{
resp.sendRedirect("../init.jsp");
}
resp.sendRedirect("../login.jsp");
}
}
他报如下错误:
Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Errortype Exception reportmessage Internal Server Errordescription The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.exception java.lang.NullPointerException
at indexServlet.service(indexServlet.java:28)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:446)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 
此问题还在困扰,请各位帮忙啊
在JB6用TOMCAT3.2可以通过,在TOMCAT4.1.21下不通过?
将几个文件代码简单写出:
indexServlet.java文件为:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class indexServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;
charset=GB2312";
//Initialize global variables
public void serive(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
String cmd=req.getParameter("cmd");
if(cmd==null)
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("login"))
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("logout"))
{
resp.sendRedirect("../logout.jsp");
}
resp.sendRedirect("../login.jsp");
}
}
login.jsp文件为:
<style type="text/css">
</style>
<form name="form" method="post" action="dologin.jsp" target="_top">
<center>
<table width="32%" border="0">
<tr>
<td align="right" width="21%">username:</td>
<td>
<input type="text" name="username" size="20" class="input">
</td>
</tr>
<tr>
<td align="right" width="21%">password:</td>
<td>
<input type="password" name="password" size="20" class="input">
</td>
</tr>
<tr>
<td width="21%">
<input type="submit" name="Submit" value="Submit">
</td>
<td>
<input type="reset" name="Submit2" value="Reset">
</td>
</tr>
</table>
</center>
</form>
index.jsp文件:
<% response.sendRedirect("servlet/indexServlet");
%>
应该说很简单的,但就是出错,请各位指点。多谢了!
 
首先,要保证能正常访问http://youserver/appdir/servlet/testservlet.
我将你的文件稍微改动了一下,因为我不明白index.jsp是干啥的
流程是 先访问q1.jsp 什么也不填 ,提交后,servlet转向到login.jsp
或直接在浏览器的URL输入"http://myserver/mydir/servlet/indexServlet?cmd"
也可转向到login.jsp
我的环境为Linux 8.0+tomcat 4.1.18+ j2sdk1.4
q1.jsp
<html>
<body>
<form method=post action="servlet/indexServlet" >
Please Input your name:
<input type=text name="cmd">
<input type=submit value="submit">
</form>
</body>
</html>
login.jsp
<style type="text/css">
</style>
<form name="form" method="post" action="dologin.jsp" target="_top">
<center>
<table width="32%" border="0">
<tr>
<td align="right" width="21%">username:</td>
<td>
<input type="text" name="username" size="20" class="input">
</td>
</tr>
<tr>
<td align="right" width="21%">password:</td>
<td>
<input type="password" name="password" size="20" class="input">
</td>
</tr>
<tr>
<td width="21%">
<input type="submit" name="Submit" value="Submit">
</td>
<td>
<input type="reset" name="Submit2" value="Reset">
</td>
</tr>
</table>
</center>
</form>
indexServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class indexServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html;
charset=GB2312";
//Initialize global variables
public void service(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException
{
String cmd=req.getParameter("cmd");
//String[] cmd=req.getParameterValues("cmd");
// PrintWriter out = resp.getWriter();
// out.println(cmd);
if(cmd==null)
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("login"))
{
resp.sendRedirect("../login.jsp");
}
if (cmd.equals("logout"))
{
resp.sendRedirect("../logout.jsp");
}
resp.sendRedirect("../login.jsp");
}
}
 
接受答案了.
 

Similar threads

后退
顶部