获得运行servelt程序的问题。 [英] Getting problem to run servelt program.

查看:88
本文介绍了获得运行servelt程序的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在servlet上的第一个程序,我遇到了一些问题。我使用tomcat 5.5作为servlet容器(服务器),与这个servlet关联的三个文件是



home.html

this is my first program on servlet and i am getting some problem.I am using tomcat 5.5 for servlet container(server), three files associated with this servlet are

home.html

<html>
<head>
 </head>
 <body>
 <form action="trialpath">
  <input type=submit values="aa" name=ab/>
   </form></body></html>





firstservlet.ja va



firstservlet.java

import javax.servlet.*;
public class firstservlet extends GenericServlet
{
   public void service(ServletRequest req,ServletResponse)throws IOException,ServletException
   {
      res.setContentType("text/html");
      PrintWriter pw=res.getWriter();
      pw.println("this is for testing");
   }
}





web.xml文件



web.xml file

<web-app>
<servlet>
<servlet-name>trial</servlet-name>
<servlet-class>firstservlet</servlet-class>
 </servlet>
<servlet-mapping>
<servlet-name>trial</servlet-name>
 <url-pattern>/trialpath</url-pattern>
  </servlet-mapping>
 </web-app>





现在我的servlet文件编译成功,我已经将这三个文件粘贴在tomcat主目录的这个模式中



1)webapps / root / home.html

2)webapps / root / firstservlet.java

3.webapps / root / web-inf / web.xml

4)webapps / root / web -inf / classes / firstservlet.class



1



执行这些操作后我尝试运行我的servlet程序使用



now my servlet file is compiled successfully and i have pasted these three files in the this pattern of tomcat home directory

1)webapps/root/home.html
2)webapps/root/firstservlet.java
3.webapps/root/web-inf/web.xml
4)webapps/root/web-inf/classes/firstservlet.class

1

after doing these when i am try to run my servlet program using

http://localhost:8080/home.html"





i我收到一条错误页面的消息找不到



i am getting a message as error page with "Not found

The requested URL /home.html was not found on this server" rather than getting the right answer.



i我尽​​力不能解决问题请帮助我。谢谢


i am trying my best not able to get the problem please help me. thanks

推荐答案

先生,您能告诉我该怎么做
sir can you please tell me that what should i do


这篇关于获得运行servelt程序的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆