###前提・実現したいこと
P.56図▼サーブレットの実行結果、のような結果にならない。
###発生している問題・エラーメッセージ
ブラウザにHTTP Status404-と表示される。
###該当のソースコード
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.example; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * * @author yuuichi */ @WebServlet(name = "Servlet01", urlPatterns = {"/Servlet01"}) public class Servlet01 extends HttpServlet { /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet Servlet01</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Servlet Servlet01 at " + request.getContextPath() + "</h1>"); out.println("</body>"); out.println("</html>"); } } // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code."> /** * Handles the HTTP <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Returns a short description of the servlet. * * @return a String containing servlet description */ @Override public String getServletInfo() { return "Short description"; }// </editor-fold> }
###試したこと
課題に対してアプローチしたことを記載してください
特に何もしていません
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
P.42でGlassFishを起動したところ様々な警告文が出る。 Launching GlassFish on Felix platform 6 11, 2017 11:52:06 午前 com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner 情報: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner. 6 11, 2017 11:52:07 午前 com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations 警告: Skipping entry because it is not an absolute URI. 6 11, 2017 11:52:07 午前 com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations 警告: Skipping entry because it is not an absolute URI. 6 11, 2017 11:52:07 午前 com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner startBundles 警告: Can not start bundle file:/C:/Users/yuuichi/GlassFish_Server/glassfish/modules/core.jar because it is not contained in the list of installed bundles. Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime@5ccb921f in service registry. #!## LogManagerService.postConstruct : rootFolder=C:\Users\yuuichi\GlassFish_Server\glassfish #!## LogManagerService.postConstruct : templateDir=C:\Users\yuuichi\GlassFish_Server\glassfish\lib\templates #!## LogManagerService.postConstruct : src=C:\Users\yuuichi\GlassFish_Server\glassfish\lib\templates\logging.properties #!## LogManagerService.postConstruct : dest=C:\Users\yuuichi\GlassFish_Server\glassfish\domains\domain1\config\logging.properties 情報: Running GlassFish Version: GlassFish Server Open Source Edition 4.1.1 (build 1) 情報: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter 情報: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created. 情報: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created. 情報: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created. 情報: Authorization Service has successfully initialized. 情報: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry 警告: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn 情報: Grizzly Framework 2.3.23 started in: 32ms - bound to [/0.0.0.0:8080] 警告: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn 情報: Grizzly Framework 2.3.23 started in: 0ms - bound to [/0.0.0.0:8181] 警告: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=admin-listener, realClassName=org.glassfish.grizzly.http2.Http2AddOn 情報: Grizzly Framework 2.3.23 started in: 0ms - bound to [/0.0.0.0:4848] 情報: Grizzly Framework 2.3.23 started in: 0ms - bound to [/0.0.0.0:3700] 情報: GlassFish Server Open Source Edition 4.1.1 (1) startup time : Felix (4,690ms), startup services(1,696ms), total(6,386ms) 情報: JTS5014: Recoverable JTS instance, serverId = [100] 情報: Grizzly Framework 2.3.23 started in: 15ms - bound to [/0.0.0.0:7676] 情報: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@1f52eb6f as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@44cb460e. 情報: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://192.168.1.14:8686/jndi/rmi://192.168.1.14:8686/jmxrmi 情報: HV000001: Hibernate Validator 5.1.2.Final 警告: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn 情報: Grizzly Framework 2.3.23 started in: 16ms - bound to [/0.0.0.0:8181] 警告: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn 情報: Grizzly Framework 2.3.23 started in: 0ms - bound to [/0.0.0.0:8080]
あなたの回答
tips
プレビュー