top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to process HTTP HEAD requests?

0 votes
290 views

In one particular action, I need to handle HTTP HEAD requests. Is this possible using Struts 2? What must I customize if it doesn't work out o the box?

PS: I am not using the REST plugin. This isn't a web service either. :-)

posted May 17, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Check this out [ http://axelfontaine.com/blog/http-head.html ] or maybe Struts filter just do the job ;-) If not, please request an improvement :-)

answer May 18, 2013 by anonymous
0 votes

implement ServletRequestAware interface in your action class and override

public void setServletRequest(HttpServletRequest arg0) {
 // TODO Auto-generated method stub    
 }

and use as usual

answer May 18, 2013 by anonymous
Similar Questions
+7 votes

I have an Interceptor that wants to put something in the session after the action has executed.

But if the session doesn't already exist I get an exception:

java.lang.IllegalStateException: Cannot create a session after the response has been committed

How can I determine if the session already exists from within an Interceptor?

 public String doIntercept(ActionInvocation invocation) throws Exception
 {
 String result = invocation.invoke();
 Map session = invocation.getInvocationContext().getSession();
 session.put(key, value); // throws exception if session doesn't exist
 return result;
 }
...