Results 1 to 9 of 9

Thread: How to read META-INF/MANIFEST.MF from an action?

Hybrid View

  1. #1

    Default How to read META-INF/MANIFEST.MF from an action?

    I am trying to figure out the preferred way to read my war's manifest file from within an action in webflow. I am a little stuck because I don't have access to the servlet context inside a webflow action. Is there a way to inject this into an action as a Resource? I haven't been able to figure this out - any help much appreciated.

    Thanks!

  2. #2
    Join Date
    Nov 2010
    Posts
    2

    Default

    in ur webflow action get servlet request object(from requestContext) and then using ServletContext read it.

    InputStream in = servletReq.getSession().getServletContext().getRes ourceAsStream("/META-INF/MANIFEST.MF");
    Manifest manifest = new Manifest(in);
    java.util.jar.Attributes attributes = manifest.getMainAttributes();
    System.out.println("in details..."+attributes.size());
    System.out.println("Built-By:"+attributes.getValue("Built-By"));

  3. #3

    Default

    That is all well and good, except for the fact that a webflow RequestContext is not linked to an HTTP request, and you cannot get the request object from it. Hence the point of my question. Your code will not work when passing in a flowRequestContext.

  4. #4
    Join Date
    Nov 2008
    Posts
    742

    Default

    Seems to me you should be able to get the request from externalContext.getNativeRequest(). ExternalContext is a special webflow EL variable. Maybe that's what you're looking for?

  5. #5
    Join Date
    Nov 2010
    Posts
    2

    Default

    Try this way to get HttpServletRequst

    see the methods in ExternalContext class. If your external system that has interacted with the webflow is Servlet, try something like this.

    ((ServletExternalContext)reqContext.getExternalCon text()).getRequest();

    If you are doing this in a Portlet, get portletRequest first and unwrap it to ServletRequest, then to HttpServletRequest.

  6. #6

    Default

    In my Spring Webflow app:
    context.getExternalContext() returns a
    Code:
    org.springframework.webflow.mvc.servlet.MvcExternalContext
    which extends
    Code:
    org.springframework.webflow.context.servlet.ServletExternalContext
    However, the method getRequest(), as in :
    Code:
    HttpServletRequest request = (MvcExternalContext)context.getExternalContext()).getRequest();
    is protected, so I still can't get the HttpServletRequest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •