| Author |
Servlet serving Attachments
|
|
|
| Hi,
I have a portlet which generates content and has a href link in in portletView.jsp to call the servlet to open the attachment in new window ( e.g : http://localhost:9080/FileServletPr...DTest\&authFlag
=Y" target="_blank) This is an href link, everything works fine, the only issue I am having is I cann't get an attribute from Httpsession in the servlet it shows null.
This is what I m doing (using JSR168):
In PortletView.jsp
========================================
========
I create an attribute to put in the Session==> session.setAttribute("getAuth","DVSessionTest");
========================================
========
In Servlet, I want to read that session attribute but I get null. Code in the servlet:
-----------------------------------------------------------
HttpSession httpS = req.getSession();
String name = (String)httpS.getAttribute("getAuth");
----------------------------------------------------------
Any Help would be appreciated on how to get session attribute which is created in the Jsp which is part of the portlet and to retrieve in the servlet which runs as an independant App. I use Websphere Portal V5.1
| |
|
| Can I have a look at your code?
| |
|
| If you need a servlet code send me an email.
-DV
dvpunia@decisionlabs.com
| |
|
| I remember having a similar problem with passing session parameters between servlet and JSR 168 portlet. I think PortletSession supports two scopes for storing session objects Application and portlet.. Use Application scope to refer the variable in servle
t. I will try to search the url which explains this a little better. Hope this helps.
| |
|
|
|
| Hi kss17,
No I haven't solved the problem yet. I appreciate your response and the article link. I have read the article before and I have tried that approach which works fine for Portlet to Portlet communications. But what I am try to achieve is, invoke a servlet
which runs in a different app but on the same server from the portlet which will open the attachment(e.g pdf, txt ...) in a new window, the servlet and portlet all works but what I need to do on the servlet side is to get some token which will be stored i
n the portlet session through portlet jsp. This session thing doesn't seem to work between portlet and servlet.
-DV
dvpunia@decisionlabs.com
| |
|
| Hmm. Okay. I guess you would have tried to obtain the HttpServletRequest from PortletApiUtils and use HttpSession. Or try to cast the PortletSession to HttpSession in the portlet... And I also didnt look at your earlier post carefully... It says that you
r servlet and portlet are in different web app.. I think this may be the problem.. try to put the servlet in the same webapp and if see if it works.. If this also dosent work then I guess you would need to migrate the servlet to a jsr 168 portlet..
| |
|
| I have installed Portal Express and a Crystal Reports Server and I think they solved this issue using a kind of token. Portlet does a login to the webapp (Reports Server), obtains a token and then opens a report (similar to download a file).
Hope this helps. You can find the portlet sample at IBM's portlet catalog (searching for Crystal Reports or Business Objects).
|
|
|
|