File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Web service session timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Web service session timeout" Watch "Web service session timeout" New topic

Web service session timeout

venu jayaram

Joined: Mar 11, 2008
Posts: 27

I want know how to make session time out in web service.

I using Axis2 web service. in this we can manage the session in 4 type's

this is the following program that session management but i don't how to give session time out. in this program until the system shot down session is existing. please i want make 30sec session time out please tell me how to do this.....where i need to mention the session time out........

* To change this template, choose Tools | Templates
* and open the template in the editor.
package Test;

import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.service.Lifecycle;

* @author Admin
public class Myservice implements Lifecycle {

/** Sample method
private static ServiceContext sc;
public void init(ServiceContext context) throws AxisFault {
sc = context;
sc.setProperty("last", 0);

public void destroy(ServiceContext context) {

public int add(int value) {
int currentValue = value +(Integer)sc.getProperty("last");
sc.setProperty("last", currentValue);
return currentValue;


Thanks and Regards
Venu J
Vinod K Singh
Ranch Hand

Joined: Sep 30, 2008
Posts: 198
Why don't you manage session timeout using web.xml? By the way web services are supposed to stateless (not necessary) hence they should not be worried about session.

My Blog
It is sorta covered in the JavaRanch Style Guide.
subject: Web service session timeout
It's not a secret anymore!