Вообще пытаюсь просто сохранить имя логина в переменной на сервелете. Но не получается даже обратится к Post.
mypage.jsp
<%@ page import="com.login.servlet.MainServlet" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>This is page on JSP</title>
</head>
<body>
<center><h1>Hi ${log}, this is page on JSP</h1></center>
<%
String [] strings = MainServlet.getStrings();
for (int i = 0; i < strings.length; i++) {
%>
<%= strings[i]%> <br>
<%
}
%>
<input type="text" size="40" name="login" value="Loligan">
<input type="submit" value="Сохранить логин в сервелете">
</body>
</html>
MainServer.java
package com.loligan.servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;
public class MainServlet extends HttpServlet {
private Vector result = new Vector();
private int n;
String login = "no_login";
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setAttribute("log",login);
req.getRequestDispatcher("mypage.jsp").forward(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// login = req.getParameter("login");
// resp.setContentType("text/html;charset=windows-1251");
log("doPost entered");
login="newLogin";
}
public static String [] getStrings(){
return new String[]{"one","two","three"}
}