Last active
March 29, 2021 02:09
-
-
Save daichan4649/fcacff5e82a166beb6125b77181af259 to your computer and use it in GitHub Desktop.
welcome ファイルで Servlet を指定+トップページ(index.jsp)へ遷移するパターン
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
public class InitServlet extends HttpServlet { | |
private static final long serialVersionUID = 1L; | |
protected void doGet(HttpServletRequest request, HttpServletResponse response) | |
throws ServletException, IOException { | |
//TODO do something | |
// forward(--> index.jsp) | |
final String url = "index.jsp"; | |
request.getRequestDispatcher(url).forward(request, response); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" | |
id="WebApp_ID" version="2.5"> | |
<display-name>WebTest</display-name> | |
<welcome-file-list> | |
<welcome-file>init</welcome-file> | |
</welcome-file-list> | |
<servlet> | |
<description></description> | |
<display-name>InitServlet</display-name> | |
<servlet-name>InitServlet</servlet-name> | |
<servlet-class>InitServlet</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>InitServlet</servlet-name> | |
<url-pattern>/init</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment