<commit_before>package gonqbox.servlets;

import java.io.IOException;
import java.util.ResourceBundle;

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 javax.servlet.jsp.jstl.core.Config;

import gonqbox.Pages;

@WebServlet(name = "logout", urlPatterns = { "/logout" })
public class LogoutServlet extends HttpServlet{
	private static final long serialVersionUID = -5041959610547406132L;
	private ResourceBundle bundle = null;

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	String loc = Config.get(request.getSession(), Config.FMT_LOCALE).toString();
    	bundle = ResourceBundle.getBundle("ui_"+loc);
    	
		if(request.getSession().getAttribute("user") != null){
			request.getSession().setAttribute("user", null);
			request.setAttribute("index_messenger",bundle.getObject("logoutSuccess"));
		}else{
        	request.setAttribute("index_messenger_err",bundle.getObject("logoutUnsuccessful"));
		}        
    	request.getRequestDispatcher(Pages.INDEX.toString()).forward(request,response);

    }
	
	@Override<commit_msg>#70 Fixed error message from displaying when page refreshed afterlogout. <commit_after>package gonqbox.servlets;

import java.io.IOException;
import java.util.ResourceBundle;

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 javax.servlet.jsp.jstl.core.Config;

import gonqbox.Pages;

@WebServlet(name = "logout", urlPatterns = { "/logout" })
public class LogoutServlet extends HttpServlet{
	private static final long serialVersionUID = -5041959610547406132L;
	private ResourceBundle bundle = null;

	@Override
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	String loc = Config.get(request.getSession(), Config.FMT_LOCALE).toString();
    	bundle = ResourceBundle.getBundle("ui_"+loc);
    	
		if(request.getSession().getAttribute("user") != null){
			request.getSession().setAttribute("user", null);
			request.setAttribute("index_messenger",bundle.getObject("logoutSuccess"));
		}
		else if(request.getSession().getAttribute("user") == null){
			//user refreshed page so dialogue still appears 
			request.getSession().setAttribute("user", null);
		}
		else{
        	request.setAttribute("index_messenger_err",bundle.getObject("logoutUnsuccessful"));
		}        
    	request.getRequestDispatcher(Pages.INDEX.toString()).forward(request,response);

    }
	
	@Override
{'fraction_non_alphanumeric': 0.11559043881555477, 'fraction_numerical': 0.014270424545130217, 'mean_word_length': 5.708133971291866, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2394145', 'n_tokens_mistral': 834, 'n_tokens_neox': 791, 'n_words': 149}