Urgent : Reach a Servlet in an Portlet Application - Websphere

This is a discussion on Urgent : Reach a Servlet in an Portlet Application - Websphere ; Hello In my test environment my JSR 168 Portlet Application is reachable via these url's : a javascript resource : http://localhost:9081/.myApp/js/file.js a servlet : http://localhost:9081/.myApp/myServlet but on the production server the url's change http://localhost:9081/wps/PA_1_0_S5/js/file.js http://localhost:9081/wps/PA_1_0_S5/myServlet of course the path is ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Urgent : Reach a Servlet in an Portlet Application

  1. Urgent : Reach a Servlet in an Portlet Application

    Hello

    In my test environment my JSR 168 Portlet Application is reachable via these url's :
    a javascript resource : http://localhost:9081/.myApp/js/file.js
    a servlet : http://localhost:9081/.myApp/myServlet

    but on the production server the url's change
    http://localhost:9081/wps/PA_1_0_S5/js/file.js
    http://localhost:9081/wps/PA_1_0_S5/myServlet

    of course the path is calculated via renderResponse.encodeURL(renderRequest.getContextP ath()

    my servlet must be reachable from the outside of the portal ! How can I guess the path ?
    is there a way Is there a way to use a static name for PA_1_0_S5 ? (or simply change it ?)

    thanks for your help

  2. Re: Urgent : Reach a Servlet in an Portlet Application

    Hello Pejman,

    you need a servlet life cycle listener which outputs the servlet context
    at runtime. This is the context (starting url) you can use to reach your
    servlet. You can access then the servlet by url or include its output by
    a servlet request dispatcher.

    M.A.Bednarz
    Hannover / Germany

    Pejman PARANDI schrieb:
    > Hello
    >
    > In my test environment my JSR 168 Portlet Application is reachable via these url's :
    > a javascript resource : http://localhost:9081/.myApp/js/file.js
    > a servlet : http://localhost:9081/.myApp/myServlet
    >
    > but on the production server the url's change
    > http://localhost:9081/wps/PA_1_0_S5/js/file.js
    > http://localhost:9081/wps/PA_1_0_S5/myServlet
    >
    > of course the path is calculated via renderResponse.encodeURL(renderRequest.getContextP ath()
    >
    > my servlet must be reachable from the outside of the portal ! How can I guess the path ?
    > is there a way Is there a way to use a static name for PA_1_0_S5 ? (or simply change it ?)
    >
    > thanks for your help


  3. Re: Urgent : Reach a Servlet in an Portlet Application

    Sorry but I don't get your solution.

    my app name is myJSR168
    my servlet is reachable via http://hostname/wps/PA_1_0_V9/myservlet

    - how do you get the string PA_1_0_V9 in the listener ? (I just get myJSR168)
    - and how do you use the listener outside the portal ?

    more precision or an example would be very appreciated

    thanks




    here the listener I used
    public class LifeCycleServletContextListener implements ServletContextListener {

    public LifeCycleServletContextListener() {
    }

    public void contextInitialized(ServletContextEvent sce) {
    System.out.println("================================================== =====");
    System.out.println(sce.getServletContext().getServ letContextName());
    System.out.println("LifeCycleServletContextListener: contextInitialized");
    System.out.println("================================================== =====");
    }

    public void contextDestroyed(ServletContextEvent sce) {
    System.out.println("LifeCycleServletContextListener: contextDestroyed");
    }
    }

  4. Re: Urgent : Reach a Servlet in an Portlet Application

    sorry but I did not get your solution

    my portlet app name is myJSR168 and the servlet is reachable via
    http://hostname:9081/wps/PA_1_0_V9/myservlet

    I added a listener to my web.xml but during portal startup, thru this method : ServletContextEvent.getServletContext().getServlet ContextName(),
    I only get myJSR168 and not myJSR168_PA_1_0_V9 or PA_1_0_V9 :

    WSVR0200I: Starting application: myJSR168_PA_1_0_V9
    SRVE0169I: Loading Web Module: myJSR168.
    ================================================== =====
    myJSR168
    ================================================== =====

    So
    a) How do you get the string PA_1_0_V9
    b) how do you get the whole url from the outside of WPS, egg : http://hostname:9081/wps/PA_1_0_V9/myservlet

    any code sample would me appreciated

    regards

  5. Re: Urgent : Reach a Servlet in an Portlet Application

    M.A.Bednarz hi,

    This looks like the best approach but where would you store the context? In a property file? In a variable somewhere?

    Thanks

  6. Re: Urgent : Reach a Servlet in an Portlet Application

    huum ! I did that just to follow your instructions !
    In fact I have no idea about how to generate the servlet URL.

    Of course I could add a servlet in the wps web.xml but I didn't want to ask to the infrastructure team to change it.

    Let come back to your question :
    IF I could generate the real context egg PA_1_0_V9 in my listener, I would put it in a singleton or in the WAS cache.

    but I did not succeed ... so any suggestion is welcome

+ Reply to Thread