Retrieve a session outside the servlet/JSP

Hi,
I know that we usually use the following code to retrieve the session:
HttpSession session = request.getSession();
but what if we don't have the request.
In my case I want to access the session to save some information before going to my tierP (JSPs + Action beans, ...) to be able to retrieve them after.
Is the only way to do so would be to pass the session in param to my TierB ?
Thanks for your help!

I guess I also have to mention that I don't have access to a database... our databases are on our old mainframe (Cobol), then we are only connecting to the mainframe to get all the info we need, but once on the Java side I need to keep some information in my TierB if possible.
For more details, I receive 1-9 questions from the mainframe everytime I link to it, but I don't want the TierP to deal with all those questions, then I would like to save them in the session in the TierB and always pass only 1 question to the TierP. When I get back to the TierB, I have to check if there are questions left, if not, link back to the Cobol side, if so, just pass the next question.
This is a very small summary, but I think that you should have the main idea.
Thanks again!

Similar Messages

  • Can the servlet/jsp engine be brought down

    Hello,
              Can the servlet/jsp engine be scheduled for a "in-house patch" not affecting
              the EJB Container? That means the jsp/servlet engine is brought down.
              (HotDeploy is a development feature). Does any version of WebLogic provide
              any way to do this?
              It is a single VM and I suppose that this is not possible. Just thinking out
              loud!!
              Thanks
              Gaurav
              

    Sorry, but there's no way to apply a hot-patch to the server. Good idea, but
              very tricky to implement!
              If you were using a cluster with session-replication, you can cycle the
              servers one at a time. The other servers will pick up where the
              downed-server was working. You can then apply the patch, and bring up the
              server again. Give it a few minutes (an hour to be safe!) to replicate from
              the running server, then cycle the other server safely.
              Alex
              "Gaurav Khanna" <[email protected]> wrote in message
              news:3c7c1256$[email protected]..
              > Hello,
              >
              > Can the servlet/jsp engine be scheduled for a "in-house patch" not
              affecting
              > the EJB Container? That means the jsp/servlet engine is brought down.
              > (HotDeploy is a development feature). Does any version of WebLogic provide
              > any way to do this?
              > It is a single VM and I suppose that this is not possible. Just thinking
              out
              > loud!!
              >
              > Thanks
              > Gaurav
              >
              >
              >
              >
              

  • Configuration of sessions for deployed servlet, jsp, wdp

    Hello,
    I wonder how to configure session for a specific servlet. As there are several locations where to deal with session management.
    I have found the Security Provider->SessionExpirationPeriod property which is fixed to ~27 hours, this is a general parameter for all security providers.
    I need to do it per application, I have then tried to set the session in the servlet descriptor it is not taken into account.
         <session-config>
              <session-timeout>10000</session-timeout>
         </session-config>
    The security provider of the servlet is set to SAML authentication.
    Thanks for your input on this topic,
    Tanguy Mezzano

    Finally, it was that parameter.

  • Launching a Preview Session Outside the ATG Business Control Center

    I have setup a remote preview server on ATG 10.1.1. Everything works great when viewing it inside the BCC however I’m wondering how to access the preview server outside the BCC. According to the ATG documentation, it sounds like that’s possible. The ATG docs state:
    “Users can preview project asset changes outside the framework of the Business Control Center. For example, you might want employees or outside reviewers who do not have access to the Business Control Center to evaluate changes to a Web application while it undergoes development. In this case, you can enable preview on servers that do not have the Business Control Center installed, then give reviewers URLs to the launch pages on these servers. They can invoke these URLs from any browser window.
    Note: Users who are not logged into the Business Control Center can invoke preview sessions only with URLs to a server where the Business Control Center is not running. In order to avoid security breaches, URLs to preview sessions on the Business Control Center server are blocked.”
    This is the only information I found in the documentation that talks about viewing preview outside the BCC. Based on this limited information, there are a lot of questions I have about how this actually works.
    1. Any attempt to hit any page on my remote preview server outside the BCC, I see the following exception:
    “ERROR [PreviewProfileRequestProcessor] An attempt was made to preview a project without logging in as a user with access to publishing assets. If you are running a local preview instance, the preview URLs registered with the PreviewURLManager may be misconfigured. Ensure that the preview URLs are configured with the same host and domain name used to access the BCC server. This preview request URL is: http://localhost:8280/sample_catalog/index.jsp. If you are running a remote preview instance, the Preview feature does not support remote preview on servers running the BCC. Ensure that the remote preview instance is not running any of the BCC related modules. If you received this error and did not try to perform a remote preview, then you may need to disable preview in the current web application by setting the atg.preview context parameter to false in the webapps web.xml file.”
    I am not running the BCC on this instance so I’m not sure why I am seeing this. Is there something configuration I'm missing here?
    2. I don’t understand where these urls would come from that a reviewer would use to preview the application. There is no "remote preview url" when previewing a page from within the BCC to copy and send to a reviewer so how would a BCC user send a url to a reviewer?
    3. Assuming the reviewing knew which page to hit in the remote preview server, how would that page use the assets from a project? Should the project id of the project be include as a param to the url?
    - Michael

    Shaik, if only it was that simple :( Do you have much experience working with remote preview or are you just guessing here like I have been? In order to help clarify my post though, here is the scenario that describes the basis for my questions:
    A business user is working on a project within Merchandising of the BCC
    1.     The user makes a change to a category
    2.     The user clicks the Preview Button on the tool bar
    3.     The system displays the Preview launcher screen
    4.     The user selects a pre-configured profile user and page for the preview session
    5.     The user clicks the Flexed based launch button
    6.     The application displays within the context of the BCC browser/tab
    7.     The business user would like to send that url to a reviewer who does not have access to login to the BCC
    What happens from step 6 is that a giant iframe launches from within the context of the BCC browser/tab. If you are using remote preview, it is still an iframe and still displays within the context of the BCC browser/tab, the only difference is that the BCC is proxying information to the preview instance in order to initialize the preview session to display the application in the context of the business user’s project. The url the user sees in the browser is the url for the BCC, not the remote preview server. Because the UI for Merchandising and Preview is built using Flex, there is no way to click on the Preview button to open it up in another tab or browser. The only way your suggestion would work is if there is a way to configure the Flex UI to have it open up preview in a new browser/tab which I doubt is possible.
    I hope this helps better explain my post. With that said though, this brings me back to my original questions.

  • How to find the servlet, jsp version available for SunOne 7 webserver

    hi ,
    I am looking for a command that can say the version of servlet, JSP container in Sun One7 webserver.
    as in weblogic we can do by command
    java weblogic.version -verbose
    is similar type of command is available for SunOne 7 web server

    Hi,
    Ask BASIS person to check the JMS driver which is installed on XI through visual admin.
    Thnx
    Chirag

  • Session in the servlet

    Hi!
    A Netbeans web application use some servlets, not jsp, and tomcat, and postgre sql.
    The big problem is executing some querry after the jdbc connection was closed, or can't open a new jdbc connection because too many are open, for example. And the session in some situations lost who is the logined user :) This was the application probem. If you have any idea to solve tham please anounce me.
    My problem is I don't know how to check if the session is valid or not in the folowing function:
    protected void processRequest(HttpServletRequest request, HttpServletResponse response){
    request.getSession();
    // how to check that session???
    }

    Thank's, how to do that? Where to find some samples, tutorial?

  • Maintain session when calling servlet from form in a JSP

    I have the following set up:
    index.jsp calls login servlet from the action tag in a form.
    Login servlet handles the login, stores the user info and db connection in the session and uses forward(req,res) to call another jsp.
    That jsp has a form where user enters search info and in that form's action tag there is a search servlet. In the search servlet I am unable to access the session.
    Is there any way to pass the session to the servlet from that jsp using a form/action?

    I've read elsewhere that if you go from a jsp to a servlet that the >request object is cleared of any attributes from the previous request.which is correct. But arent we speaking about session object here? A request object is valid for a request - ie the phase from where the server receieves a hit for a resource upto the point it sends the output for that request.
    A session spans multiple requests.
    it doesn't retrieve the session info and gives me a null pointer >exception when I try to use the connection object stored in the session.Bad bad bad . Why do you store Connection objects in session? Create them when necessary or use a connection pool. Do you for example clean up the connections when the session expires. What if its a 30 minute session and the user hits every say 15 minutes with a request. Why do you need to hold on to the Connection in the intervening interval when the user's session is inactive?
    gives me a null pointer exception when I try to use the connection object stored in the session.which means that the Connection object is null - not the session object.
    That last line is where I get the null pointer exception. And that is
    Statement stmt = con.createStatement();?
    Same answer as above.
    If the session object was null,
    userSession.getAttribute("connection");would have thrown a NPE.
    ram.

  • Unable to retrieve a session attribute

    My program gets a set of input from the users via a jsp page and moves on to another jsp(intermediate) wherein i get these input values through request.getParameter and set it as session values to be sent to a servlet. When I try to retrieve these values in the servlet it shows null value. I find that the sessionId of the jsp and that of the servlet seems to differ. Why is that so? while the reverse works well (i.e) creating session parameters in servlet and accessing this session in jsp. The program works only if I put the values in application scope which I feel is not necessary.

    817456 wrote:
    I find that the sessionId of the jsp and that of the servlet seems to differ. Why is that so? Hard to answer. Under normal operating circumstances, you will not get this behavior. a cookie will be set with the jSessionID and you will have the same session no matter if you invoke a JSP or servlet (a JSP is also a servlet, so there is absolutely no difference).
    So you do not have normal operating circumstances. It might be a server setting, it might be a browser setting, but god knows which one. It might be something else in the environment; for example, do you have a regular Apache HTTP server hooked up before your Java web server?
    Another thing to check; when you are in your JSP, is a jSessionID appended to the url in the browser?

  • How to -only- invoke a Servlet/JSP

    Hi,
    I would like to invoke a Servlet or JSP inside a standalone application WITHOUT opening a stream. When I use url.openConnection() or con.connect() the servlet/JSP is not executed, I must also do "ObjectInputStream o = new ObjectInputStream(con.getInputStream());" in order to get the servlet/jsp executed.
    I just want to invoke the servlet/JSP, because I use the returned data for nothing.
    Thanks

    If you openConnection, you might also have to get the output stream from the servlet to make it work properly. (Otherwise, the server, or proxies in-between, might consider that the client has decided it doesn't want the page after all, and may stop requesting it.)
    A cheap way to request a page but get less data back would be..
    conn.setRequestMethod("HEAD");HEAD is exactly like GET, except it doesn't return the body (just the headers, hence the name.) Not entirely sure if it works on Java.
    Failing that, you should be able to just open the input stream, and close it again straight away.

  • Urgent: how to run applet which connected to the servlet?

    hi frends:
    i have written an applet on the server side and it supposed to pass parameters to my servlet and retrieve some info from the servlet.
    i put both applet and servlet under tomcat../WEB-INF/classes. but when i run the applet from the web browser, there is no response from the servlet.
    could anyone help me to solve this problem?
    one more thing is i know that applet is able to connect to servlet, but how about java application? is it able to do so? if yes, is it also using URLconnection as applet? and how to run it?
    i will be very appreciate if anyone can help me... thanx a million.

    You can connect to the servlet from an application.There's a URL class in java.net that has an openConnection method. Then cast the return to an HttpURLConnection and use setMethod to set up as a post request.This may be the default if you call setDoOutput(true) on the URLConnection. Then you'll need to get an OutputStream and write properly formatted form POST data to it. It's also possible to encode your data on the URL, even when using the POST method, and this may be easier when doing it programmatically from an application. To send a get request you can append the name-value pair at the end of the url.

  • Tomcat can't get the specified jsp-page.

    there are three jsp-page : Step1.jsp Step2.jsp Step3.jsp
    Step2.jsp and Step3.jsp are placed at the same folder,but Step3.jsp is placed at the different folder.
    Step1.jsp's content :
    request.getRequestDispatcher("/CH4/Step2.jsp").forward(request,response);
    Step2.jsp's content :
    <form name="form1" action="Step3.jsp" method="post">
    <input type="submit" name="submit" value="submit">
    </form>
    Step3.jsp's content :
    <c:out value="can you see this page " />
    the expectent procedure is : Step1 -> Step2 ->Step3
    but there is error : The requested resource (/CH4/MyJspCode/Step3.jsp) is not available.
    how to currect it ?

    The action on your form will be relative to step1.jsp
    So it will look for step3.jsp in the same folder as step1.jsp.
    This is because:
    The request was for step1.jsp
    The action attribute is a relative reference, not absolute, and thus is relative to the requested url - step1.jsp
    Although it was forwarded to step2.jsp, the browser knows nothing of this, and thus uses step1.jsp as its base.
    You can change this by including a base tag on the page.
    You can also give an absolute reference to the servlet/jsp but that involves harcoding the context name into the URL.

  • Servlet/JSP question

    Hello guys I have just been reading the HeadFirst Servlet/JSP book from O'REILLY.
    I have used it as a workbook just to see how the framework are use. After ending this book I have planned to do some stuff by my self. I'm precisely in the last chapters of the book right now so I thought about headed toward the Servlet/JSP API. Well in there I found out that the information about JSP were all just about stuff which concerned the Container. I didn't find anything about the syntax used in JSP, the EL syntax nor how the JSTL 1.1 tags looks like! And there where nothing about the DD.
    So I'm wondering were I could fins this information, and why they aren't reserved in the JSP API?
    Another question, when was the JSP2.0/Servlet2.4 specification released?

    Which edition of the book were you reading? It should have covered EL and JSP syntax right?
    Servlet2.4/JSP2.0 has been around for at least 5 years. Can't remember the exact date, but the specification was finalised November 2003.
    The JSP API is from the programming perspective. Tag library documentation is seperate.
    Useful links for you:
    [JSP reference |http://java.sun.com/products/jsp/docs.html] - JSP tags and EL.
    [JSTL Apis|http://java.sun.com/products/jsp/jstl/reference/api/index.html] THE reference for JSTL. Don't be afraid of the JSTL specifications. They are quite readable, and document all the JSTL tags fully. I refer to them constantly.
    Cheers,
    evnafets

  • Disable tomcat servlet & jsp examples

    Running apache 2.0.63 on my nw65sp8 server, using it to host my web
    page. Server is also running tomcat 4.1 for misc other things such as
    GW webaccess.
    I'm wondering what I need to do to 'disable' the servlet & jsp examples
    from being available from my webpage.
    IE, so if I go to the following urls, nothing happens:
    http://my_web_page/examples/servlets/index.html
    http://my_web_page/examples/jsp/index.html
    https://my_web_page/examples/servlets/index.html
    https://my_web_page/examples/jsp/index.html
    Thanks,
    Stevo

    Nevermind, got it.
    In the portion of my httpd.conf where I'm loading the jk_module stuff
    (IIRC I had to put this stuff in for webaccess), I rem'd out the line
    to jkmount the examples.
    Stevo

  • Session Rules from Servlet to JSP

    I'm getting a null pointer exception from the else statement in the JSP below when I check to see if a user has been authenticated by a servlet.
    Are there any problems with the else statement to cause an exception?
    <% /**Verify Authenticationt*/
    HttpSession mysession = request.getSession();
    String loginUrl = "/hr/servlet/SessionLoginServlet";
    if (mysession==null)
    response.sendRedirect(loginUrl);
    else {  //below code causing null pointer exception
    String loggedIn = (String) mysession.getAttribute("loggedIn");
    if (!loggedIn.equals("true"))
    response.sendRedirect(loginUrl);
    %>
    The Servlet's doPost:
    public void doPost(HttpServletRequest request, HttpServletResponse
    response)throws ServletException, IOException {
    String userName = request.getParameter("userName");
    String password = request.getParameter("password");
    if (login(userName, password, response)) {
    //send cookie to the browser
    HttpSession session = request.getSession(true);
    session.setAttribute("loggedIn", new String("true"));
    response.sendRedirect("/hr/jsp/PAStart.jsp");
    else {
    sendLoginForm(response, true);
    }

    Unfortunately, no. You'll need to say:
    if (loggedIn != null || !loggedIn.equals("true"))
    It's how the equals() works for String objects. You need two objects to check equality.

  • How do I lookup an EJB 3.0 Session bean from servlet or JSP?

    Does anyone knows how can I invoke an EJB from a servlet or JSP ?
    I deployed a simple EJB on a Oracle Application Server 10g release 10.1.3 and I'm working with JDeveloper 10.1.3. I deployed the files via JDeveloper, and I didn´t specify any orion-ejb-jar.xml or ejb-jar.xml file
    After deployment, the orion-ejb-jar.xml look like this in the server:
    <?xml version="1.0" encoding="utf-8"?>
    <orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd" deployment-version="10.1.3.0.0" deployment-time="10b49516c8f" schema-major-version="10" schema-minor-version="0" >
    <enterprise-beans>
    <session-deployment name="HolaMundoEJB" location="HolaMundoEJB" local-location="HolaMundoEJB_HolaMundoEJBLocal" local-wrapper-name="HolaMundoEJBLocal_StatelessSessionBeanWrapper6" remote-wrapper-name="HolaMundoEJB_StatelessSessionBeanWrapper7" persistence-filename="HolaMundoEJB.home_default_group_1">
    </session-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping name="<default-ejb-caller-role>" impliesAll="true" />
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>
    I'm trying to invoke the ejb in a servlet by doing the following:
    public void doGet(HttpServletRequest request, ....
    Context context = new InitialContext();
    HolaMundoEJB helloWorld =
    (HolaMundoEJB)context.lookup("java:com/env/ejb/HolaMundoEJB");
    String respuesta = helloWorld.sayHello("David");
    When i invoke the servlet I catch a NamingException whose message says something
    like this ....java:com/env/ejb/HolaMundoEJB not found in webLlamaEJB
    I tried different paths for the lookup but nothing....
    Can anyone help me with this topic? Thank you.

    Please try the following code:
    HelloEJBBean.java:
    @Stateless(name="Hello")
    @Remote(value={Hello.class})
    public class HelloEJBBean implements Hello {  ... }
    hello.jsp:
    Context ctx = new InitialContext();
    Hello h = (Hello)ctx.lookup("ejb/Hello");
    web.xml:
    <ejb-ref>
    <ejb-ref-name>ejb/Hello</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>fi.kronodoc.test.model.Hello</remote>
    </ejb-ref>
    i think you should also define jndi mappings for the references in orion-ejb-jar.xml and orion-web.xml but for some reason it seems to be working also without these.

Maybe you are looking for