こんにちは、サーブレットから JSP ページにデータを渡そうとしていますが、null を取得します。どこが間違っているのか教えてください。これが私のコードです:
MyConnection.java
public void doGet (HttpServletRequest inRequest,
HttpServletResponse outResponse) throws ServletException,
IOException {
inRequest.setAttribute ("ST", "QWERTY");
RequestDispatcher dispatcher = inRequest.getRequestDispatcher ("/index.jsp");
out.print ("\ n" + dispatcher);
dispatcher.forward (inRequest, outResponse);
}
index.jsp
<% @ page contentType = "text / html" pageEncoding = "UTF-8"%>
<% @ page language = "java" import = "java.util. *"%>
<! DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> JSP Page </ title>
</ head>
<body>
<form action="MyConnection" name = "myForm" method="Get">
<% = (String) request.getAttribute ("ST")%>
<% out.println (request.getAttribute ("ST"));%>
</ form>
</ body>
</ html>