初学者的提问,请大家不要笑话,很着急!!

bryantd 2006-07-27 03:04:21
请问如果我直接在写了一个servlet类,通过编译,启动Tomcat服务器,我应该在IE的URL里写什么进行测试? 我用Eclipse+Tomcat进行测试。
package hall;

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


public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
PrintWriter out = response.getWriter();
out.print("Hello, World.");
}
}
...全文
243 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bryantd 2006-07-31
  • 打赏
  • 举报
回复
谢谢大家!
fishyqd 2006-07-27
  • 打赏
  • 举报
回复
web.xml 可以指定
jasmine315 2006-07-27
  • 打赏
  • 举报
回复
tomcat在启动的时候,会读取server.xml,然后根据你指定的发布路径去载入你的web.xml,你得在server.xml里面指定你的发布路径,然后在你指定的发布路径下配置你的web.xml,你所写的这个HelloWorld是一个新的Servlet,那么你得在web.xml中注册该servlet
<servlet>
<servlet-name>HelloWorld </servlet-name>
<servlet-class>你的HelloWorld的包路径</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld </servlet-name>
<url-pattern>/xxx/HelloWorld</url-pattern>
</servlet-mapping>
那么你在url中输入http://localhost:8080/xxx/HelloWorld即可
wubaowang 2006-07-27
  • 打赏
  • 举报
回复
mark...
xiangxyz 2006-07-27
  • 打赏
  • 举报
回复
看你的web.xml里面怎么写了。
luc_ne 2006-07-27
  • 打赏
  • 举报
回复
比如说你建了个名字为bb的工程,放在了webapps下,则为
http://localhost:8080/bb/servlet/HelloWorld
nirvana_li 2006-07-27
  • 打赏
  • 举报
回复
http://localhost:8080/hall/HelloWorld

58,441

社区成员

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

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