score:0
Accepted answer
function calllogout() {
var a;
if(window.xmlhttprequest)
{
a=new xmlhttprequest();
}
a.onreadystatechange=function()
{
if(a.readystate==4)
{
var data = a.responsetext.split('@@');
if (data[1].trim() != null && data[1].trim() != '')
shownotification('bg-red', data[1].trim(), 'top', 'center', '', ''); // its work like alert using jquery
}
}
a.open('get','/pms-1.0.0.3/logout1',true);
a.send();
}
<a href="javascript:calllogout();"></a>
my controller
@requestmapping(path = "/logout1" , method=requestmethod.get) public modelandview logout1(httpsession session ,employeemodel employeemodel, httpservletrequest req) {
modelmap map = new modelmap();
employeemaster master = null;
system.out.println("in logout1 method");
long emp_id = (long) session.getattribute("userid");
activitytaskdetails activitytaskdetails = activitytaskrepository.getactivetaskdetails(emp_id);
system.out.println("value get from activity task"+activitytaskdetails);
if(activitytaskdetails != null){
map.addattribute("logoutvalidate","work in progress, youy cant logout.");
return new modelandview("ajaxpage", map);
}
else{
system.out.println("else part session invalidate");
session.removeattribute("username");
session.removeattribute("userid");
for (int i=0; i<global.employeerightslist.size(); i++) {
session.removeattribute("employeerights_"+global.employeerightslist.get(i).getformmaster().getformname());
}
return new modelandview("redirect:/login");
}
}
ajax page
<c:if test="${logoutvalidate != null}">
@@${logoutvalidate}
</c:if>
Source: stackoverflow.com
Related Query
- How To get String Response using spring controller in ajax and base of that perform action?
- How to get the role that a user logged in with in my controller using Spring Security
- in spring framework how to get response from controller to jsp page by ajax call passing an id value to controller
- How to return autocomplete result to spring mvc controller using ajax and jquery
- How to produce json response that consumes json object using spring and Hibernate
- How to get all request parameter names and values in a form submitted using ajax in spring MVC?
- Using query string to get a response from controller and displaying it in same page
- How to download file from server using jQuery AJAX and Spring MVC 3
- Spring MVC : Redirecting from a base controller - How to get the path to redirect to?
- How to get response in JSON format using @ExceptionHandler in Spring MVC
- How to log spring JdbcTemplate sql queries and DB response in log file using log4j2
- Using ajax post,get, put, delete etc Vs html post and get only in spring pros and cons
- How do I render a JSON view/response via AJAX using Spring MVC annotation-based controller for portlets?
- How can we get and set response body in Spring Boot Filter
- How to upload file using ajax file upload and spring mvc?
- How to get ID of currently logged in user using spring security and Thymeleaf
- How to get some utf-8 characters using hibernate and spring mvc in database?
- How to make a REST call from Spring MVC Controller and return the response as it is
- How to Pass List using Ajax call to Spring MVC Controller
- What is the correct way to send a string using AJAX with Spring and Thymeleaf? Status : 400
- How to bind 2 GET methods in Spring MVC and distinguish using @RequestMapping?
- Questions about how inheritance affects Spring Controller classes when using a base controller class
- Error in uploading a file in spring and capturing response using ajax
- Receive parameters in Rest controller from Post method using Spring and Ajax
- How to get user sessionid , requested url to subscribe and user information during a websocket call using spring security
- Using Spring Boot, how to separately handle exception between normal request and ajax request
- How to accept GET argument in Spring boot Controller and return appropriate object
- How do I send a request to another domain and get the response body in a Spring MVC controller?
- Get the map from controller using ajax call in spring
- How to deserialize response json with Spring RestTemplate using Builder Pattern and @JsonDeserialize
More Query from same tag
- UserDao is null, I am wiring the bean wrong and need help
- How to set a formatter for Jackson JSON?
- spring security concurrent session not working
- how to authenticate user using spring security?
- Spring 4.2.0 - How to use SimpUserRegistry
- “params” in @RequestMapping annotation not working Spring MVC
- Spring interceptor vs servlet filter
- Spring @ExceptionHandler - apply to json producing @RequestMapping only
- Spring Interceptor for BasicDataSource
- How to get JSON response from Spring Controller to JQueryAjax?
- PUT method HTTP Status 400 in Spring MVC - AngularJS
- 405 Method Not Allowed http method being used: Request method 'GET' not supported` in spring-security
- Failed to convert property value of type [java.lang.String]
- Angular 5 cannot read headers of response from Spring application
- org.springframework.web.bind.ServletRequestDataBinder cannot be cast to org.springframework.web.bind.support.WebRequestDataBinder
- Remove whitespace in HTML created by JSP comments
- spring mvc + spring aop + aspectj
- No suitable driver found for jdbc:mysql://db4free.net:3306/partnerdb
- Spring Boot @ControllerAdvice exception handler not firing
- HTTP 404 Spring MVC with Tiles no XML
- Spring MVC: Complex object as GET @RequestParam
- Spring Data JPA – @Query – Not supported for DML operations
- Custom WebAuthenticationDetails programmatically in spring security
- Spring Security multiple filterChainProxy mapping/filters, custom filters Json Output
- MVC Design Pattern and Controllers in JavaFX
- the redirected page is not being displayed in spring-mvc ajax GET request
- Cross field validation with HibernateValidator displays no error messages
- JSTL c:import strange behaviour with xml file
- How to get the pojo class object say Employee in controller class using spring 4 annotation
- return url when using Spring MVC form based authentication