Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing paramter from a j2ee app to Portal ?

12 views
Skip to first unread message

Neeraj Sidhaye

unread,
Jan 7, 2009, 8:15:25 AM1/7/09
to
Hi,

I want to pass a parameter from a j2ee web app to IBM Portal 6.0.
The scenario is like, i have a j2ee web app and there is link called MyAccount.
As soon as user clicks on MyAccount link, i have to open a Portal and also i have to pass a parameter to portal on click of that link.

please suggest a solution for this...

Many thanks

bgould

unread,
Jan 7, 2009, 10:05:27 AM1/7/09
to
you have several options, none of them trivial. :) I'm sure this has been answered to death in this form already in other threads, but here are some ideas...

1) You can use the URL generation api to generate an 'offline' url, especially if your j2ee app is running on the portal server

2) You can create a filter to apply to the WPS servlet that stores the request parameters in dynacache... I know there's a developerworks article on this

3) Similarly, at the HTTP server you could store the original request URI in a custom header and read it in your portlet with PortletRequest.getProperty()

4) You can use the URI resolution framework and the POC servlet

5) If your portlet is an IBM API portlet, you can simply create a URL mapping to the page and read the parameter as you normally would in a servlet application


If you search developerWorks for 'Accessing portal content with custom URLs', the first 3 results should relate to approaches 1, 2, and 4.

Hope that helps,

Ben

Neeraj Sidhaye

unread,
Jan 8, 2009, 12:05:34 AM1/8/09
to
Hi Ben,

thanks much for the response...

i have my j2ee app running out of portal ( running in a seperate container ), and there in that j2ee web app i have a link, where i have to pass a paramter to Portal on click of that link.
so i have two queries
1) how to pass parameter from a external j2ee app to Portal ? and
2) how to retrieve that paramter in portal ( might be before or after login )

we will be using JSR 168 api for portlet development.

i think second option in your response might work for me, right ?

thanks much again..

Neeraj Sidhaye

unread,
Jan 12, 2009, 2:03:11 AM1/12/09
to
can any boby suggest a solution on this ?

thanks much

Neeraj Sidhaye

unread,
Jan 12, 2009, 8:21:35 AM1/12/09
to
would be great if anyone can suggest a solution..

thanks much...

tonitin...@gmail.com

unread,
Jan 14, 2009, 7:46:34 AM1/14/09
to
Hi Neeraj,

Somehow I managed to get this solution on internet for this type of situation (passing paramter from a j2ee app to Portal ).

Please go through the document on this link : http://www.ibm.com/developerworks/websphere/library/techarticles/0707_lynn/0707_lynn.html#download

It is saying, first you need to create dynamic cache inside your Portal Server (WPS6.0).Then create & install servlet filter in the form of jar.

I followed all the steps, I started Application Server successfully but when I am trying to start the Portal Server It is creating problem.It is not starting the Portal server, and in the SystemOut.log fir I am getting following exception :

*SRVE0026E: [Servlet Error]-[portal]: java.lang.ClassNotFoundException: com.ibm.catalog.filters.ParameterFilter*
* at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java(Compiled Code))*
* at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java(Compiled Code))*
* at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))*
* at java.beans.Beans.instantiate(Beans.java:202)*
* at java.beans.Beans.instantiate(Beans.java:63)*
* at com.ibm.ws.webcontainer.filter.WebAppFilterManager.loadFilter(WebAppFilterManager.java:287) ..........*

I am making jar file with name InvokePortal.jar.

Can anyone suggest where I am making mistake.

manyt...@gmail.com

unread,
Jan 19, 2009, 12:32:12 PM1/19/09
to
Hi,
why don't have a look at wp.l2.url.helper.jar. Include this jar and try in this way.

String targetURLStr = ServletURLHelper.generateUrl("CustomUniqueName of the portal page which you have to render", CustomUniqueName of the Portlet (it should be generated using xmlaccess only),HashMap (you can pass parameters), HttpServletRequest, HttpServletResponse);

response.sendRedirect(targetURLStr);

Hope this may work.

Regds,
Anil

Neeraj Sidhaye

unread,
Jan 20, 2009, 7:11:53 AM1/20/09
to
Hi Anil,

thanks for your reply..

the solution you suggested will work only when parameters are required to pass from a servlet/portlet within a portal to any page/portlet on the same portal. right ?

my requirement is to pass a parameter from an EXTERNAL J2EE APP ( running in a separate container/machine) to PORTAL.

Thanks again

http://ExtremePortal.blog.co.uk

Ryan Wilson

unread,
Jan 20, 2009, 7:19:56 AM1/20/09
to
So you need to a stand-alone J2EE application (running on a different server) to be able to create a URL to pass to portal?

If so you could create a Servlet running in portal that will generate the URL. Then in your stand-alone app call this servlet to get the URL.

Ryan

SCJP & SCWCD
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

Neeraj Sidhaye

unread,
Jan 20, 2009, 8:24:33 AM1/20/09
to
Hi Ryan,
thanks for the reply...

as you said, "create a Servlet running in portal that will generate the URL"..here i don't want servlet running in portal to create url for me.
I want a servlet should be in a external j2ee app that should be able redirect to portal along with parameter ( might be as query string). And then in portal i should be able to get those parameters.

here i am again explaining my query

i have my j2ee app running out of portal ( running in a seperate container ), and there in that j2ee web app i have a link, on click of that link i have to pass a paramter to Portal.


so i have two queries
1) how to pass parameter from a external j2ee app to Portal ? and
2) how to retrieve that paramter in portal ( might be before or after login )

hope you got my issue...if not please feel free to come back....because if i got a solution for this then i would be able to perfrom SSO as well.

Thanks much..
**
*http://ExtremePortal.blog.co.uk*

Ryan Wilson

unread,
Jan 20, 2009, 8:39:51 AM1/20/09
to
Neeraj,

I understood your requirements. Unfortunately you cannot generate a portal URL from outside of portal. The URL Generation APIs need portal and the portal libraries to generate the URL. So this is why I suggested using a servlet running on portal to generate the URL, you could also use a WebService.

The flow would be like this.

1.) Your j2ee app running outside of portal would make a request to portal to generate the URL
For example you could do the following:
http:// : /wps/MyServlet?targetPortlet= &targetPage=....
This Servlet running on portal would generate the URL using the helper APIs mentioned earlier in the thread and return this URL to your application.
Or you could use WebServices to accomplish the same.

2.) You j2ee app could now use this URL to direct the user to the specific page/portlet in WebSphere Portal.

Neeraj Sidhaye

unread,
Jan 20, 2009, 9:42:47 AM1/20/09
to
Hi Ryan,

yeah..this looks good approach..
but i have one query on this, how can we directly access a servlet running on portal ?
As you said, just call this "http:// : /wps/MyServlet..."

As far as i know i can do this when i can create a Java project ( will include wp.l2.url.helper.jar file into build path to use ServletURLHelper class to generate ua rl to a page and portlet) with a ServletFilter and then will export this project as jar. I will put this jar into /shared/app
Now i would go to web.xml of /cell../../../wps.war and will make an entry of that filter servlet.
I think this way i can directly hit a servlet running on portal from outside environement, am i right ?

Because when i see the web.xml of wps.war i can see the portal and myportal entries as FilterServlet, in the same way i can add my own filter servlet to the web.xml and can invoke my own servlet.

Am i thinking right ?

thanks much,
**
*http://ExtremePortal.blog.co.uk*

Ryan Wilson

unread,
Jan 20, 2009, 10:03:57 AM1/20/09
to
Yes this is what I was referring to. Although you would use a Servlet and not a ServletFilter.

Ryan Wilson

unread,
Jan 21, 2009, 7:34:59 AM1/21/09
to
Check the Java level of your Java project in RAD. I assume it is set to 1.6, you will need to change it to 1.5

Neeraj Sidhaye

unread,
Jan 21, 2009, 7:29:40 AM1/21/09
to
[2] com.ibm.ws.classloader.ExtJarClassLoader@1f668717 Local ClassPath: D:\IBM Portal\WebSphere\PortalServer\shared\app;D:\IBM ......and so on..

these are the thing i performed.

1) Created a java project in RAD with a servlet, added wp.l2.url.helper.jar file to the build path.
Now to use ServletURLHelper i have to add WebSphere Portal v6.0 JRE, and the WebSphere Portal v6.0 runtime libraries to the project.
(As described in IBM Tech note "Portal 6.0 Advanced URL Generation Helper classes", under the heading 'Modifying the code' at the end of note

http://www-01.ibm.com/support/docview.wss?rs=688&context=SSHRKX&dc=DB520&uid=swg21265900&loc=en_US&cs=UTF-8&lang=en&rss=ct688websphere )

2) i exported this porject as jar and then copied to portal-server/shared/app
3) edit the web.xml of wps.war and added an entry of my servlet.
4) restarted the portal server and app server.


now when i hit the portal url like
http://localhost:10038/wps/MyParameterServlet?dealerID=dealer2009

i am getting the linkageError exception as i explained above.

please suggest where i am doing wrong and how to solve the above error


thanks much..

**
*http://ExtremePortal.blog.co.uk*

Neeraj Sidhaye

unread,
Jan 21, 2009, 8:57:57 AM1/21/09
to
i have checked my JDK compiler compliance level in RAD and it's 5.0.

is that right ? what could be cause for this error....

thanks..

Ryan Wilson

unread,
Jan 21, 2009, 9:01:39 AM1/21/09
to
Could you upload your JAR including the source?

Nitin Pancholi

unread,
Jan 21, 2009, 9:37:26 AM1/21/09
to
Hi Ryan,

This is Nitin & I am working with Neeraj on this issue.
I am replying on behalf of Neeraj. Attacing the JAR (with source) file, please suggest where we are making mistake.

Neeraj Sidhaye

unread,
Jan 22, 2009, 7:41:48 AM1/22/09
to
Hi Ryan,

did you get a chance to look into the jar file ?
Though, this is just a sample servlet what we have written and in the code initially we are just trying to fetch the parameter passed from an external j2ee app and then later in the code we will use ServletURLHelper to redirect to a page/portlet.

thanks for all your support...

appreciated a lot..

**
*http://ExtremePortal.blog.co.uk*

Ryan Wilson

unread,
Jan 22, 2009, 7:50:44 AM1/22/09
to
Ahh... you're on portal 6.0. I had thought you were on 6.1.
The JDK level of the Java app needs to be 1.4

Neeraj Sidhaye

unread,
Jan 22, 2009, 9:15:04 AM1/22/09
to
ohh cool..
thanks Ryan..

i have changed the JDK level to 1.4 and then copied the updated jar to shared/app

After this i hit my serlvet using url

http://localhost:10038/wps/MyParameterServlet?dealerID=10045

the *good news* here is, my servlet got hit and i am able to get this parameter in my servlet.

later in code, after retrieving the params i am putting this parameter in a map and passing this map to generateURL method.
and then i am using ServletURLHelper class to hit my portlet as follows..
String targetPortalURL = ServletURLHelper.generateURL( , , map, request, repose);
and on this portlet i would retrieve those parameter from map.

but here the issue is, i am getting the following error when i call generateURL method

[1/22/09 19:46:03:702 IST] 0000003e WebApp E SRVE0026E: [Servlet Error]-[MyParameterServlet]: java.lang.NoClassDefFoundError: com/ibm/wps/l2/urlspihelper/servletrequest/ServletURLHelper

the required jar (wp.l2.url.helper.jar) is already present in my project's lib foler.
do i need to put this jar in portal/shared/app ??

please suggest, what could be the cause of this issue ?

i am almost very near to solve this problem...

thanks much again...appreciated lot..

**
*http://ExtremePortal.blog.co.uk*

Ryan Wilson

unread,
Jan 22, 2009, 9:25:30 AM1/22/09
to
Yes the JAR should be placed in shared/app

Neeraj Sidhaye

unread,
Jan 22, 2009, 10:09:12 AM1/22/09
to
hey...excellent it worked....
my page and portlet got hit from the generateURL mehtod from servlet.

but, i passed map from servlet to portlet using generateURL method and in portlet how can i retrieve that map ??

i have used renderRequest.getParameterMap() in doView of portlet to retrieve that map, is that right way to retrieve that map in portlet ?

thanks much Ryan...

**
*http://ExtremePortal.blog.co.uk*

Neeraj Sidhaye

unread,
Jan 23, 2009, 1:53:58 AM1/23/09
to
Hi Ryan,

finally everything worked and now i am able to hit and pass param to portlet from an external j2eep app.

Many Thanks...

i have another query on the same scenario, explained below:-

for now, i have kept my ParameterRetrievealPortlet on welcome page and assigned Anonymous access rights to portlet, and when user hits the servlet, the servlet generates url,passes parameter and redirects to the generated url.
But, when i don't assign Anonymous access rights to ParameterRetrievealPortlet, then generateURL method doesn't take me to the appropriate page/portlet and shows me the login portlet page.
So this means, ParameterRetrievealPortlet has to have Anonymous access rights,
am i correct ?
what if after logging into portal if need those parameters ,
can i use Credential Vault in ParameterRetrievealPortlet and store them into Valut, so that i can access those parameter from any portlet application deployed on portal ?

please suggest...


Many thanks Ryan...

**
*http://ExtremePortal.blog.co.uk*

Ryan Wilson

unread,
Jan 23, 2009, 6:54:31 AM1/23/09
to
If you are accessing this portlet/servlet from an external J2EE app then you need it to be unauthenticated correct?

Neeraj Sidhaye

unread,
Jan 23, 2009, 8:01:50 AM1/23/09
to
yes totally agreed...it has to be unauthenticated...

and what if later on after logging into portal if need those parameters ?

can i use Credential Vault in ParameterRetrievealPortlet ( anonymous accessed protlet ) to store those param into Vault, so that i can access those parameter from any portlet application deployed on portal ?

thanks...

**
*http://ExtremePortal.blog.co.uk*

0 new messages