In login.java I am using req.setAttribute("username", req.getParameter("username"));
and in welcome.jsp I am using Hello ${username}
but Intellij gives me the warning:
Cannot resolve variable 'username'
The variable works. Why do I get this warning?
login.java
package ch.yourclick.zt;
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;
@WebServlet("/login")
public class Login extends HttpServlet {
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setAttribute("username", req.getParameter("username"));
req.setAttribute("password", req.getParameter("password"));
req.getRequestDispatcher("/welcome.jsp").forward(req, resp);
}
}