hrefを使って、jspからサーブレットに移動したいのですが、フォルダが無いです、と言われエラーが出ます。
java
1ファイル名;index.jsp 2<html lang="ja"> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <title>JUMSトップ</title> 6</head> 7<body> 8 <h1>トップ</h1><br> 9 <a href="Insert">新規登録</a><br> 10</body> 11</html>
java
1ファイル名;Insert.java 2 3import java.io.IOException; 4import javax.servlet.ServletException; 5import javax.servlet.http.HttpServlet; 6import javax.servlet.http.HttpServletRequest; 7import javax.servlet.http.HttpServletResponse; 8import javax.servlet.http.HttpSession; 9 10public class Insert extends HttpServlet { 11 12 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 13 throws ServletException, IOException { 14 HttpSession session = request.getSession(); 15 session.setAttribute("ac", (int) (Math.random() * 1000)); 16 request.getRequestDispatcher("../insert.jsp").forward(request, response); 17 } 18 19}
java
1ファイル名;insert.jsp 2<html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5 <title>JUMS登録画面</title> 6 </head> 7 <body> 8 </body> 9</html> 10
WebApplication4
-----Webページ
---------index.jsp
---------insert.jsp
ソース・パッケージ
---------jum1
-------------Insert.java
と言う階層です、
<a href="/WebApplication4/Insert">新規登録</a><br>
<a href="../Insert">新規登録</a><br>
も試したんですがダメでした。初歩的な気がするのですが、とろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー