求助,当要编译.java文件,需要导入jsp-api.jar时怎么做啊?

may12 2006-03-06 08:53:41
如题,顺便问一句在tomcat中一定要设classpath吗?除了这些还有什么要设的啊?
...全文
163 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
may12 2006-03-06
  • 打赏
  • 举报
回复
但编译,说缺少class和interface,怎么回事啊?
may12 2006-03-06
  • 打赏
  • 举报
回复
我的代码

DispatcherServlet.java


package mypack;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class DispatcherServlet extends HttpServlet{

private String target="/hello.jsp";
public void init(ServletConfig config)
throws ServletException
{
super.init(config);
}
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException
{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
String username=request.getParameter("username");
String password=request.getParameter("password");

request.setAtrribute("USER",username);
request.setAtrribut("PASWORD",password);
ServletContext context=getServletContext();

System.out.println("Redirecting to "+ target);
RequestDispatcher dispatcher=
context.getRequestDispatcher(target);
dispatcher.forward(request,response);

}
public void destroy()
{}

}
may12 2006-03-06
  • 打赏
  • 举报
回复
怎么加用户啊,加了有什么用啊?
kill8108 2006-03-06
  • 打赏
  • 举报
回复
第一个问题:引入jsp-api.jar,你把这个包加到环境变量中就可以了吧!
一般我配tomcat的时候,就只把包加到环境变量中,和在tomcat-users.xml中加一个用户吧,其它的没什么配的了!

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧