Using HttpSession

Hi! I need to store sessiondata between a portlet and a regular jsp file (the jsp file is called from a portlet). As I see it it's not possible to use ProviderSession in a regular jsp file. So I've tried to create a HttpSession object. However, the jsp file always creates a "new" HttpSession, hence I can't pick up the stored sessiondata the portlet created. Is there other ways to do this? Maybe provided with a small example? Of course, the portlet and the jsp is on the same OC4J instance.

Hy,
My Source:
PortletRenderRequest prr = (PortletRenderRequest) request.getAttribute(HttpCommonConstants.PORTLET_RENDER_REQUEST);
String actionLink = HttpPortletRendererUtil.htmlFormActionLink(request, PortletRendererUtil.PAGE_LINK);
String linkBack = prr.getParameter("_page_url");
String eventSubmit = EventUtils.eventName("submit");
String hiddenFields = HttpPortletRendererUtil.htmlFormHiddenFields(request, PortletRendererUtil.PAGE_LINK);
if ( prr.getUser().isLoggedOn() )
//user is logged on, so get session
ProviderSession providerSession = prr.getUser().getSession(true);
this.SessionId = providerSession.getId();
out.println("User is logged in!!!<br>");
else
out.println("User is NOT logged in!!!<br>");
//user not logged on, so session will be null
if (prr.getParameter(eventSubmit) == null)
String Object = "success";
//prr.getUser().getSession().setAttribute("NameOfObject",Object);
out.println("<form method=\"POST\" action=\"" + actionLink + "\">");
out.println(hiddenFields);
out.println("<input type=\"Submit\" name=\"" + eventSubmit + "\" value=\"OK\">");
out.println("</form>");
out.println("<br> SessionId=" + this.SessionId);
} else {
//String temp = (String) prr.getUser().getSession().getAttribute("NameofObject");
out.println("<br> SessionId=" + this.SessionId);
//out.println("<br> Attribut=" + temp);
out.println("<br> <a href=\"" + linkBack + "\">zurück</a>");
No own provider-instance...
Thanks again...

Similar Messages

  • How to get multiple values using HttpSession.getAttribute(java.lang.String)

    Hey Guys
    I'm trying to find a way to get multiple values using the following method
    HttpSession.getAttribute(java.lang.String)
    Here's the scenerio. Its a already written application and now i'm trying to make some changes. earlier in the jsp page a combo box was used and value was retrieved in the servlet using the getAttribute method of Session. Now I'm using a html multiple selection list and have to retrieve all the values selected in the list in the servlet. Can anyone please suggest me how to do that. HTTPRequest class has a method getParameterValues which will let me do that but i have to do is using HTTPSession.
    Thanks for your time to read this

    I'm not sure what you are trying to do. You can only use session.getAttribute to retrieve something that has already been stored in the session with a previous setAttribute. If you need to store multiple values under one attribute name using setAttribute, you can store an array, or an ArrayList or whatever type of Collection you want. The request.getParameterValues method is the only way you can retrieve form parameters than can have multiple values. If the servlet hasn't already processed these parameters and put them into the session for you, you have to use request.getParameterValues.

  • How to customize the message using HttpSession info in WL-PubServer

    Hi, im using Weblogic 10.3 Publish-Subscribe Server (PubServer) in order to create Comet application.
    http://e-docs.bea.com/wls/docs103/webapp/pubsub.html
    We are utilizing JMS Message system to support Clustered environment, and everything works great and as expected, however now we need to support sending User Customized data like (Internationalized Messages, date formatted in user timestamp preference and others).
    Since we are posting the payload updates into JMS in a subsystem this 'User Preference (stored in HttpSession) is not accessible'. My goal is to try to put a hook into WL PubServer mechanism that delivers the message to the client(which is attached to an specific Channel) and be able to customize the Data (using HttpSession information) before it gets delivered.
    I have researched about this for the past few days without luck, also trying to search information about the com.bea.httppubsub.servlet.ControllerServlet which is the responsible to handle this but again always end in a dead end. I'm starting to think this is not possible at all (at least with the current WL PubServer).
    I'll be glad to hear any feedback on this.

    Hi,
    Sender object is type of object any time if you want to use any property/attribute of sender object first you need to type cast it with your desire object.
    For more information, you could refer to:
    http://blog.jsinh.in/managing-msmq/#.VPe5mnkfqM8
    http://forums.asp.net/t/343932.aspx?How+can+I+get+values+of+sender+object+in+C+
    Regards

  • Use of HttpSession and Performance Issues

    I am working on an application where we are storing data in a user's HttpSession. The application consists of several modules. Each module consists of sub-modules. A sub-module contains various data which is display to the user as multiple tabs with each tab displaying a JSP. The data displayed on each JSP is stored in the HttpSession for a given browser window. So if the user only has one browser window open there will be one entry in the HttpSession for that window containing the data for the various tabs of the displayed sub-module.
    This effort has been a transition of a legacy Powerbuilder application over to the Web. We have noticed, along with the users :( some delays in displaying data. We only connect to the database during the initial retrieve of the data. Once the data for a sub-module is retrieved it is displayed and stored in the HttpSession. As the user makes modifications we modify the appropriate structure in the HttpSession. When the user Saves the data, that is when we make a connection to the back end database.
    What is the best way to determine if there are true performance issues or whether we are just experiencing the cost of doing business across the Web?
    Does using HttpSession cause potential performance issues?
    We are also using the Netui tags in the JSP's and we have discovered some overhead when tag ids are used. In most places we have removed the tag ids since extra script is generated when they are used in conjunction with the Netui tags. This has helped in some places with the rendering of data on a page.
    Anyone have any suggestions/ideas?
    Thanks in advance.
    Michelle

    Is anybody using MODEL in production?
    How is the performance - is there any real problems?I used a MODEL query last year to simulate a FIFO queue and calculate average stock prices.
    It performs pretty well, but the volume of data is small though (~200k rows processed per batch session).

  • Use request attributes in JSF

    Is there a way we can pass data from one form bean to the other using request attributes insted of session attributes?
    I am able to work with session attributes using
    HttpSession mySession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true); and setting attributes to it, but getting null pointers(occassionally) when I retrieve the atribute and work with it.
    getSession(false) isnt helping either.
    Looks like facesServlet is creating a new request when it forwards to next page. Any idea on how to get the Faces Servlet do something like request despatcher forward, for navigation so I can work with request attributes?
    Appreciate your input.

    Can I have just one backing bean and use it for all jsps in the app? App has 4 flows from home page and mutiple jsps in each flow. Each jsp has multiple form fields. Is that OK?
    Any way to passing data/objects between different backing beans - other than using session attributes? I had similar problems working on Struts app as well.

  • HttpSession

    I have an application in JHeadStart.
    On load of my application, there is a java class who gets one parameter from request:
    //DataActionContext daContext
    daContext.getHttpServletRequest().getParameter("Tipo");
    But during this application I need store this parameter, then I store this on HttpSession, but when the user load another instance of this application, the HttpSession is the same of the others.
    I need an applicationScope to store datas by application and not by Session.
    How can I do this?

    Hi!
    Try storing your data in the ServletContext, using HttpSession.getServletContext() if that's what you need. Data stored there will be accessible from every session.
    This used to be mapped to "applicationScope" in UIX.
    Sascha

  • Cookies...I need alternatives to using them...

    I need to create a text only version of the portal to meet
    requirements of the Federeal Gov't's Disabilities Act...
    So, I'm scraping the content of the Portal Pages (pages from
    v1.0.2.2) by basically creating another middle tier (db ->
    application server -> scraper -> browser).
    The issue is COOKIES. I loose them at the "scraper" tier. And
    for some reason, I can't retrieve the Oracle Portal generated
    cookies from the client machine. The result is a "security
    error" when rendering portlets on a page with non-public access
    requirements.
    So, how can I maintain the user's session WITHOUT the use of
    cookies? I would think this would have to be done for the WAP
    version of the portal...but then again, maybe not.
    Please help!
    Thanks,
    Ryan Stefani

    Hi,
    How abt using HttpSession ? This is one of the modes of session
    maintenance in a J2EE scenario. Typically, when you go for a MVC
    architecture in Java, a controller (a servlet, which typically
    maintains session info), a view (a JSP, which is called from the
    servlet and also the UI) and a model (an EJB, which represents
    data). This class is in Servlet API.
    Hope this helps,
    --Rajesh

  • Read HttpSession Variables in Multiples Projects...

    I'm using JDeveloper 9.0.3 with BC4J+UIXML, and I have the problem:
    One session varible using HttpSession created in the Project "A", don't be used in Classes of Project "B", after deploy processes.
    Example:
    Project "A"
    file1.uix - invoking Java Class FunSessionVar (create session variables and call file2.uix in Project "B"):
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    import oracle.cabo.data.jbo.servlet.bind.*;
    import oracle.cabo.ui.data.BoundValue;
    import oracle.cabo.ui.data.DataBoundValue;
    import oracle.cabo.servlet.util.RedirectUtils;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServletRequest;
    public class FunSessionVar
    public static EventResult FunPrepSessionVar(BajaContext context
    ,Page page
    ,PageEvent event) throws Throwable
         HttpServletRequest req = context.getServletRequest();
         HttpSession sess = req.getSession(true);
         sess.setAttribute("CodPessoaEscola", event.getParameter("CodPessoaEscola"));
         sess.setAttribute("DspNomEscola", event.getParameter("DspNomEscola"));
         Page browsePage = new Page(page, "../ProjectB/file2.uix");
         return new EventResult(RedirectUtils.getRedirectPage(context, browsePage));
    Project "B"
    file2.uix - have a "null" event invoking Java Class FunReadSessionVar (read session variables and set View Object Query):
    import oracle.jbo.ViewObject;
    import oracle.cabo.servlet.BajaContext;
    import oracle.cabo.servlet.Page;
    import oracle.cabo.servlet.event.PageEvent;
    import oracle.cabo.servlet.event.EventResult;
    import oracle.cabo.data.jbo.servlet.bind.*;
    import oracle.cabo.ui.data.BoundValue;
    import oracle.cabo.ui.data.DataBoundValue;
    import oracle.cabo.servlet.util.RedirectUtils;
    import javax.servlet.http.HttpSession;
    import javax.servlet.http.HttpServletRequest;
    public class FunReadSessionVar
    public static EventResult FunPrepReadSessionVar(BajaContext context
    ,Page page
    ,PageEvent event) throws Throwable
         HttpServletRequest req = context.getServletRequest();
         HttpSession sess = req.getSession(true);
         String valor1 = sess.getAttribute("CodPessoaEscola");
         String valor2 = sess.getAttribute("DspNomEscola");
         ViewObject view = ServletBindingUtils.getViewObject(context);
         view.setWhereClauseParam(0,valor1);
         view.setWhereClauseParam(1,valor2);
         view.executeQuery();
         return new EventResult(page);
    Well, the method [b]sess.getAttribute("CodPessoaEscola"); return null value, but the correct value passed in
    FunSessionVar (Project "A") is equal "180".
    Any body have a solution for this problem ?
    Thans,
    Danilo

    John, thanks for your help...
    The event parameters does not have null values, because if I write this command in the Pages of Project "A", the show values are correct:
    <flowLayout>
    <contents>
    CodPessoaEscola:
    <styledText data:text="text@getCodPessoaEscola" />
    </contents>
    </flowLayout>
    (The Data Provider return HttpSession variable of CodPessoaEscola).
    May be HttpSession variables have restrict scope inside Project ? Does the web.xml file have properties to configurations of this feature, before make deploy ?
    Thanks,
    Danilo

  • Portal Runtime Error when communicating from JSPDynPage to JSP Using Bean

    Hi ...
    I am pursuing this problem for quite sometime now. Even opened a high priority message with SAP. We are using a bean to communicate value between a JSPDynPage and a JSP. When trying to access the bean in the doProcessAfterInput of the JSPDynpage, sometimesi get a nullpointer exception ..as if the bean was released ..
    I have tried ComponentProfile, ComponentSession... but in vain. If i try to use HTTPSession, the initialization of the bean in the JSP fails since its scope is applicationIt also fails if i try and reduce the scope of the bean.
    Pls advice. I can post the code on request.
    Thanks,
    Devina

    I believe application has a larger scope than session ..
    Here's the extract of the code
    public void doInitialization() {
    IPortalComponentRequest request =(IPortalComponentRequest) this.getRequest();
              IPortalComponentResponse response =     (IPortalComponentResponse) this.getResponse();
              IPortalComponentContext compcontext = request.getComponentContext();
    zOrgStructBean.setOrgData(aOrgData);
                                  zOrgStructBean.init(); //initialize bean
                   //compcontext.putValue("OrgSelectionBean", zOrgStructBean);
                   myProfile.putValue("OrgSelectionBean", zOrgStructBean);
    public void doProcessBeforeOutput() throws PageException {
              IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
              compcontext = request.getComponentContext();
         this.setJspName("TeamViewer.jsp");
         request = (IPortalComponentRequest) this.getRequest();
              request1 = request.getServletRequest();
              compcontext = request.getComponentContext();
              IPortalComponentProfile myProfile = compcontext.getProfile();
    zOrgStructBean =(OrgSelectionTreeBean) myProfile.getValue("OrgSelectionBean");
    ...// bean is returned as null
    JSP
    <%@ page import="com.hersheys.hr.pcr.exit.HersheyTeamViewerExitBean"%>
    <%@ page import="com.hersheys.hr.pcr.exit.OrgSelectionTreeBean"%>
    <%@ page import="java.util.*"%>
    <%@ page import="com.sapportals.portal.prt.component.*"%>
    <%@ page import="com.sapportals.htmlb.TreeNode"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="OrgSelectionBean" scope="application" class="com.hersheys.hr.pcr.exit.OrgSelectionTreeBean"/>
    <jsp:useBean id="myTableViewBean" scope="application" class="com.hersheys.hr.pcr.exit.HersheyTeamViewerExitBean"/>
    <hbj:content id="myContext" >
    <hbj:page title="AIP TeamViewer" >
            <hbj:form id="myFormId">
                   <%  int j = myTableViewBean.getSelectedRow();
                        pageContext.setAttribute("myRootNode", OrgSelectionBean.getTree());
                    OrgSelectionBean.renderTree(myFormId);
    Bean
    public void init(JCO.Table TableData) {
              Object[] colTitle ={"Name","ID"};
              Object[] colTitleB = {"Forms"};
              data = new Object[TableData.getNumRows()][2];
              bdata = new Object[3][1];
              bdata[0][0]="Termination";
              bdata[1][0]="Retirement";
              bdata[2][0]="Death";
              int j = 0;
                        //int i;
              for (int i = 0; i < TableData.getNumRows(); i++) {
                             //HersheyTeamViewerAIPBean zAIPBean = (HersheyTeamViewerAIPBean)TableData.getRow(i);
                   j = 0;
              //for (JCO.FieldIterator e = TableData.fields(); e.hasMoreElements(); ){
                   JCO.FieldIterator e = TableData.fields();
                   while (e.hasMoreElements()) {
                             JCO.Field field = e.nextField();
                             data<i>[j] = field.getString();
                             j = j + 1;
                        TableData.nextRow();
              this.model = new DefaultTableViewModel(data, colTitle);
              this.setOldTableViewModel(data, colTitle);
              bmodel = new DefaultTableViewModel(bdata, colTitleB);

  • Maintaining session using SOAP

              Hi I am trying to deploy our application in a clsutered environment. Previsouly
              I had some problems with http session replication. That problems were solved but
              now I have another problem.
              Our application has multiple clients, some are browser based and some are swing
              based that use our SOAP services.
              all browser based clients use httpsession for session management, since weblogic
              replicates the httpsession, we have no problem clustering http webapps. But SOAP
              services has no access to httpsession.
              We have implemented our own session management (we cache the app specific session
              objects) so that SOAP services works fine (SOAP services doesn't have access to
              httpsession, so we could not use httpsession for session management).
              Each method in our soap services takes a sessionid and we get the session objects
              (not http session objects but our app specific session objects) based on the sessionid.
              But now that our application is clustered, the session cache mechanism doesn't
              work since its not replicated thru out the clusters.
              I thought I could use stateful session beans to cache the sessions, but how do
              I cache the SFSB thru out the session w/o sending any references to the SFSB to
              the client. I know I can send the Handle reference to the client but We cannot
              change the SOAP API now. The only information client has is the session id.
              My question is: How do I use SFSB w/o changing my soap services method paramaters.
              My SOAP method looks like methodName(String sessionid, ..............)
              I could use a clustered cache but we can't buy anything in the current situation.
              Any help would be appreciated.
              Praveen
              

    Yes Srinivas,
    ur scenario should work.It doesnot matter if u r treating System A as sender as well as receiver.I guess u r created a outbound interface and from that u have created the client WSDL.And for reciver side u r already having a WSDL.
    so ur scenario is SOAP<->XI<->SOAP.
    now u can send ur request by any SOAP editor like XML SPY/SOAPUi.
    and if ur configuration is correct u should get the response.
    regards
    biplab

  • HTTPSession with URLConnection

    Does URLConnection support HTTPSession?
    I need to write an Applet that uses HTTPSession and
    I wondered if that could be done with URLConnection?
    best regards
    dr sykero

    If you mean that you should be able too keep your httpsession alive each call to the HTTPserver, then
    one idea is to read the answer of the URLConnection the first time the HTTPServer creates the sesssion. Retrieve the sesssionId, and repost it every time you make a new connection.
    I believe the sessionId is located somewhere in the HTTPheader.
    /Andreas

  • Using deployment descriptor authentication

    Hello,
    I'm working on a web application and want to have a login for anyone that accesses the service. Is it possible to use the deployment descriptor to implement security but using my own authentication method? What I want to do is something like this; have my web.xml similar to this:
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>all private</web-resource-name>
    <url-pattern>/*</url-pattern>
    </web-resource-collection>
    </security-constraint>
    <login-config>
    <auth-method>FORM</auth-method>
    <form-login-page>/login.jsp</form-login-page>
    </login-config>
    But, in my login.jsp, instead of having <form action="j_security_check" ...
    I'll do something like <form action="tryLogin" ... and I'll implement my own login method that will use HttpSession to validate/invalidate the session. The reason I'm trying to do things this way is that I want to have username/password pairs stored on mySQL on my server. I am using the struts framework and the latest version of Tomcat. If anyone knows if this would work or if there is an easier way to do this please let me know!! Thanks!

    Yup. It can be done having "tryLogin" as a servlet/jsp which retrives the username and pwd from the request object and connects to db for validating the same

  • What are the advantages stateful session beans takes over than HttpSession

    Hi
    We can use HttpSession to maintain the conversational state with the client.
    Then why we need to go for stateful session beans to maintain conversational state with the client.
    What are advantages we can have while using stateful session beans ratherthan HttpSession????.
    Regards
    Dhinesh kumar R

    I think we can use the magic word in the software development "seperation of concerns" ;-)
    HttpSession is in the Servlet/JSP tier and is mainly used in the presentation logic tier (UI, page flows, navigation etc..)
    where the stateful session bean's concern is to maintain a conversational state in a business logic tier.
    Through this seperation its possible, that the business tier's state is undependant from the HttpSession and you dont create a hardlink that could cause problems later. Imagine having a desktop client accessing your business logic etc. not every client needs to be a web client ;-)
    I hope that the answer helps you understanding the topic :-)
    Brgds,
    Nail

  • ADF – Could I have HttpSession and EJB 3 Statefull session in same applicat

    I am using JDeveloper 10.3.2. Fist I create a single demo application to create EJB Session Bean (Statefull) and is working fine.
    When I am trying to use the same EJB to my large Application a got runtime Error,
    Without any exception. (Losing the information of EJB).
    And the Question is, Shall I use HttpSession and EJB 3 Statefull session in same application?

    Hi,
    if it is a Web application you need the https session anyway and the two are different kind of beasts, one handled by teh EJB container, the other by the web container.
    The question is why you ned stateful session beans - which seems to be a rare usecase? Usually state is persisted and tracked in the business service.
    However, without an error message its hard to tell what going wrong here
    Frank

  • Integration between portlets using JSR 168

    I've developed 3 portlets but I want them talking with each other, in a way that is JSR 168 compliant.
    For example, I have a search box portlet, where the user can only type search expressions, a search result portlet, where the user will see search results, and a search summary portlet, where the user will see statistics about search.
    First question: how can I send data from one portlet to another? Is HttpSession a safe place to share data between portlets? Can I trust that all containers will create a single HttpSession per user?
    Second question: how can one portlet force refresh of another, or even hide or show up another portlet?

    Well it is a very smart question..
    To be more precise i don't think it is been properly answered with
    JSR 168 specification.
    However,there few best practises followed in order to achieve it.
    The idea of using HttpSession (PortletSession.getHttpSession() with Usage of AJAX) as you said it certainly one of the things which evryone would think.
    http://www.ibm.com/developerworks/websphere/library/techarticles/0604_scott/0604_scott.html
    http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/
    http://wiki.java.net/bin/view/Portlet/JSR168FAQ(checkout the last part of the document)
    http://www.michaelgilfix.com/techblog/2007/01/27/ajax-and-portlets
    http://www.theserverside.com/news/thread.tss?thread_id=35385
    http://blogs.jboss.com/blog/jviet/2005/07/14/The_recurring_interportlet_communication_dilemna.txt
    http://portlets.blogspot.com/2005/07/inter-portlet-communication-library.html
    http://docs.sun.com/app/docs/doc/819-5942/6n807tpc2?a=view
    http://www.oracle.com/technology/products/ias/portal/pdf/oow06_S281756_jsr168ajax.pdf
    http://docs.jboss.org/jbportal/v2.2/reference-guide/en/html/ipc.html#d0e1308
    However,SUN is trying to revise it in their next specification JSR 286.
    http://jcp.org/en/jsr/detail?id=286,
    http://blogs.sun.com/nav/entry/understanding_portlet_2_0_jsr1,
    http://apachecon.com/2006/US/presentations/FR8/FR8-JSR-286-updated.pdf
    Second Question:how can one portlet force refresh >of another, or even hide or show up another portlet?As discussed earlier Usage of AJAX / (And storing Common Credentials in a Bean which scoped to HttpSession) in the dependent portlet would be quite handy in the above discussed case.
    Hope this might help :)
    REGARDS,
    RaHuL

Maybe you are looking for

  • Best practice for setting up iCloud with multiple devices using a single AppleID

    Hi there Me and my wife have an iPhone each, and are looking at getting both of us using iCloud. The problem is that we only use one Apple ID for our music library. Is getting a separate Apple ID necessary for each device on iCloud, or can multiple d

  • Can i upgrade an hp pavilion ze4900 laptop with an ssd?

    The hard drive is failing in an hp pavilion ze4907wm (ze4900 sold thru walmart).  Are there any special considerations for replacing the hard drive (capacity limits etc)? Can I put an PATA SSD in it? Thanks This question was solved. View Solution.

  • Is the Classic for me?

    Hi My son has an ipod touch. I was thinking of getting an mp3 player too but thought I'd try to get something less expensive. I don't want to use iTunes. But because we'll need a dock, it looks like I'll have to get an ipod. Son recommends the Classi

  • I phone 3g restore problem- error 1013

    I have recently purchased an i phone 3g from vodafone, it worked immediately but within the day it asked for system restore which i did succesfully... 2 hours later it asked again.. this time and evertime since it has tried to restore and then comes

  • Batch Export drops my Smoothcam clips!

    I have successfully added Smoothcam to a large batch of Apple Pro Res 422 HQ clips and rendered the entire timeline. I then highlight all the clips, place them in a bin in my browser, highlight and batch export them as XDCAM 1080p24 35Mbs clips. The