アプリ版:「スタンプのみでお礼する」機能のリリースについて

localhost:8080でindex.htmlを表示する代わりにServlet.classを実行したいのですがtomcat5の設定を教えてください。ちなみにlocalhost:8080/servletで実行するところまでは、本に載ってたので分かってます。

public class Servlet extends HttpServlet
{
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws IOException, ServletException
{

res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<HTML>");
out.println("<BODY>");
out.println(new java.util.Date());
out.println("</BODY>");
out.println("</HTML>");
}
}

A 回答 (2件)

index.htmlにサーブレットをマッピング(servlet-mapping)するか、welcome-file-listにサーブレットのパスを追加するかすれば良いかと思います。

    • good
    • 0

>localhost:8080でindex.htmlを表示する代わりにServlet.classを実行したいのですがtomcat5の設定を教えてください。



特に、Tomcatの設定は不要と思います。
サーブレットをweb.xmlに登録する際に、<url-pattern>を/index.htmlと登録しておけばそう認識するはずですよ。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!