Issue
Is there a request.login()
method in Java EE7? I keep getting a:
The method login(String, String) is undefined for the type HttpServletRequest
even though i have all the correct import
packages.
import java.io.*;
import java.net.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
I'm trting to implement programmatic login to access a protected page from an unprotected page. My system is using Java 7 but the example I found is going off of Java 6.
Solution
HttpServletRequest#login
is only available in Servlet spec 3.0 or greater. Ensure that youre using a jar file that complies with this version and that the servlet container (e.g. Tomcat 7 or higher) supports the functionality for this version.
Answered By - Reimeus
Answer Checked By - Willingham (JavaFixing Volunteer)