0

home.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MJ Page</title>
</head>
<body align="center" bgcolor="#FF7C7C">

<h1 align="center" style="padding-bottom:20rem;"> Welcome to MJ Page</h1>
<h2 style="padding-bottom:4rem; padding-left:2rem;"> Login Form </h2>
<form action="login" method="post">
    Email Id <input type = "text" name="emailid" required/><br/><br/>
    Password <input type = "password" name="pass" required/><br/><br/>
<input type  = "submit" role="button">
</form>

</body>
</html>

Loginfilter.java

package com.linuxx;

import java.io.*;


import javax.servlet.*;

import javax.servlet.annotation.WebFilter;
import javax.servlet.http.*;
@WebFilter("/login")
public class Logmport javax.servlet.annotation.WebFilter;
import javax.servlet.http.inFilter implements Filter {
       
 
    
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse res = (HttpServletResponse) response;
        HttpSession session = req.getSession(false);
        System.out.print(session==null);


    }

}

Initially I go to localhost:8080/DemoApp/home.jsp but I didn't create any session in that, but the session is created somehow and when I print (session==null) it shows false but its supposed to return true.I even tried restarting the server... help!

0 Answers0