Session is lost when going from a servlet to a jsp

Any help would be greatly appreciated.
          I can sucessfully go from my jsp page to the Servlet. When in the servlet I have a service method where I place the information from my form on the jsp on a bean. Then I do a session.setAttribute("aBean", aBean) to place the bean in the session. Then do a req.sendRedirect("my.jsp"). Watching it in the debugger, when we leave the servlet our session is cleared and when we do a jsp:usebean to get the bean session from the session it creates a new bean so all the information is gone that was there before. here is my usebean tag where we are getting it from scope,
          <jsp:useBean id="aBean" scope="session" class="com.MyBean"></jsp:useBean>
          Thanks, Trucker

<jsp:useBean name="helper" scope="session" class=".."/>
          <jsp:useBean name="helper" scope="session" type=".."/>
          ·class="package.class"
          Instantiates a bean from a class, using the new keyword and the class constructor. The class must not be abstract and must have a public, no-argument constructor. The package and class name are case sensitive.
          ·type="package.class"
          If the bean already exists in the scope, gives the bean a data type other than the class from which it was instantiated. The value of type must be a superclass of class or an interface implemented by class.
          If you use type without class or beanName, no bean is instantiate
          In your case you already instantiated the bean “com.MyBean” in servlet and you set bean in session scope. But you are not accessing that bean from servlet. Instead of that you are crating a new bean instance by using class attribute of <jsp: useBean>. So if you want to access the bean already created in servlet you should use type attribute instead of class in <jsp: useBean>. So you have to change your code as follows.
          <jsp:useBean id="aBean" scope="session" type="com.MyBean"></jsp:useBean>
          Then you will not lose the bean created in servlet.
          - Navaneeth

Similar Messages

  • Ability to print to a pdf lost when going from Acrobat 9 to 11

    I upgraded from Acrobat 9 standard to 11 standard and have lost the ability to print to a pdf. Where do i go to add a pdf printer? The PDF printer icon in the "printers and faxes area" has been removed.
    Thank you

    You will have to provide system info and other details. This is way too generic/ vague.
    Mylenium

  • Hi When going from Develop module to print module a white boarder appears on screen which also prints via my epson r3000 printer. I can get round this by exporting photo to Elements and printing from there but can i get rid of the boarder and print from l

    Hi When going from Develop module to print module a white boarder appears on screen which also prints via my epson r3000 printer. I can get round this by exporting photo to Elements and printing from there but can i get rid of the boarder and print from lightroom?

    In the printer driver (accessed through the Page Setup button) set the Advanced tab to borderless. Then in the right hand panel under Layout set all the margins to zero.

  • When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?

    When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?
    Thanks, Rich

    In order to be cross platform you must be using the Open Type version of all fonts to cause the least disruption. Macs can read and process the Windows .ttf  type format but PCs can't process Mac formatted type. Most recent versions also cannot use the older PS Type 1 fonts.

  • Print issues when going from develope to print

    In LR5 when going from Develope to Print, I loose the picture and the print tab is greyed out.  Never had this problem before, did I do something wrong

    Make sure the source remains the same - check the filmstrip.
    The only suggestion is to place the batch for editing and printing into a collection or (temporary) quick collection and access the images from there in both modules.

  • How to display outsream from a servlet in a JSP

    I wrote a jsp file to call a Servlet, then want to display the result from the servlet in another jsp file. Anyone can give me possible solution or an example to illustrate it.
    Many thanks in advance.
    the file that call servlet in a jsp is as follow
    <form method="POST" action="myservlet">
    <table>
    <tr>
    <th align="center" colspan="2">
    Enter The query words
    </th>
    </tr>
    <tr>
    <th align="right">query words:</th>
    <td align="left">
    <input type="text" name="querywords" size="60">
    </td>
    </tr>
    <tr>
    <td align="right">
    <input type="submit" value="Search">
    </td>
    <td align="left">
    <input type="reset" value="Reset">
    </td>
    </tr>
    </table>
    </form>
    ............

    I would suggest that you use the Servlet to retrieve the data you are after and store it in the session. Then forward the user onto the JSP page where it can retrieve the object from the session and present it to the user in a formatted view.

  • How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

    Hi guys,
    How do I Display a string from a servlet into a JSP Page...
    Ive tried so many bloody things!.....
    Simply.
    I get text from JSP. The servlet does what ever it does to the string.
    Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
    please help!!!

    hmmm, I dont really like using JSP programming, u should be using JAVA..
    the way to do it is:
    Call and cast to the bean like this:
    <%@ page import="beans.*" %>
    <% //cast to bean get request create object
    userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
    then... all you do is call it like this:
    <input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
    this is the real programmers way,,,
    chet.~

  • Challenge forwarding from a servlet to a JSP

    Redirecting information from a servlet to a JSP
    Hello Everyone,
         I am processing the contents of a html form using a servlet. After processing the
    information received and storing it into a javabean I am trying to pass control onto a jsp for
    display. At this stage the jsp does not display as desired due to a URL challenge. The URL
    which references my jsp is:
    http://localhot/ferngully/prefset.jspThis url has been designated to the jsp page 'prefset.jsp' by the application specific web.xml
    file (...I am using Tomcat 5!), the relevant contents of which follow:
    <servlet>
         <servlet-name>PreferenceSet</servlet-name>
         <jsp-file>/prefset.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
         <servlet-name>PreferenceSet</servlet-name>
         <url-pattern>/ferngully/prefset.jsp</url-pattern>
    </servlet-mapping>If I access the page with the afore mentioned URL it displays correctly. However the URL which
    is returned to the browser after the servlet has forwarded control to the JSP is:
    http://localhost/ferngully/ferngully/PreferencesThe following form markup is used to access the servlet:
    <form name="form1" method="post" action="ferngully/Preferences"> I know that I have mapped the servlet correctly because the servlet performs it's programatic tasks happily :)
    I am using code within the servlet to forward control to the JSP, and I believe that this is the crux of my challenge.
    The code for the servlet is listed below.
    package userpreferences;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class PreferencesServlet extends HttpServlet
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
              String url = "/prefset.jsp";
              ServletContext servCont = getServletContext();
              RequestDispatcher reqDispatch = servCont.getRequestDispatcher(url);
              reqDispatch.forward(request, response);
    }I believe that the above highlighted code section is responsible for my challenge. I have tried changing the String url to "/ferngully/prefset.jsp",
    however there was no improvement in functionality.
    Can somebody please explain to me how I can go about directing the control of this process from the servlet to the jsp correctly? Particularly
    how I can go about making the url returned to the client correct for accessing the jsp page? Do I need to delete the mapping entry for the
    jsp page in web.xml? I am new to servlets & jsp so any help will be much appreciated.
    Thanks
    Kind Regards
    Davo

    3. >The following form markup is used to access the servlet:
    <form name="form1" method="post" action="ferngully/Preferences">Question 1:
         why do you specify your contextname in action attribute again ?
         General funda about urls:
         When you have an index.html loaded through http://localhost/index.html, then a link in that html whose url is,
         1. say, preferences.html (no forward slashes preffixed or suffixed) would load the html from the same folder.
         2. say, /ferngully/prefences.html, would attempt to load a html from the ferngully folder that is a sub-directory
    of your web-application
         3. say, /ferngully/prefences.jsp, would attempt to load a html from the ferngully folder that is a sub-directory
    of your web-application
         When you have a servlet whose url-pattern is set to intercept requests, it would intercept requests that have that
    pattern it is defined to intercept in web.xml (for example all the above requests in 1,2 and 3 would be intercepted
    by a servlet whose pattern is ferngully/*)
         Now if your action is not a specific resource (.jsp or .html), something like /preferences, this would map to a url
    /ferngully/preferences. (for which a resource should be defined in web.xml - either a servlet or a jsp)
    However the URL which is returned to the browser after the servlet has forwarded control to the JSP is:
    http://localhost/ferngully/ferngully/PreferencesTell us the url of the original html
    I know that I have mapped the servlet correctly because the servlet performs it's programatic tasks happily :)Tell us the url-appetrn of the servlet that intercepted your request
    Particularly
    how I can go about making the url returned to the client correct for accessing the jsp page?The url in the browser is always the request url, you cannot change it to the url of the jsp even which rendered the page
    through a fwd from the servlet.
    Do I need to delete the mapping entry for the
    jsp page in web.xml?Not necessary. You can access the jsp directly from the servlet while forwarding by
    1. specifying the exact path to the jsp. For example if the jsp is under a folder called jsps, your request dispatcher
    url ought to be /jsps/prefset.jsp
    2. specifying the jsp's url-pattern as specified in web.xml
    Questions Contd
    2. Why does the url pattern have to have a .jsp suffixed.
    From your code
    <url-pattern>/ferngully/prefset.jsp</url-pattern>It could equally well have been
    <url-pattern>/ferngully/prefset</url-pattern>And then your servlet would have to forward it to ("/ferngully/prefset")
    2. Your jsp-file mapping is in this form
    <jsp-file>/prefset.jsp</jsp-file>This assumes that the jsp is in the top-level folder of your web-application and not under
    any sub-directories. Correct ?
    cheers,
    ram.

  • Problems losing quality when going from develop module to library module ??  anyone have a fix

    Problems losing quality when going to library module from develop module.  Sharpness and color quality decrease

    This is normal. There will be a difference as you are comparing Library Previews with the image in Develop which accesses the original file, although the difference is usually slight. Real results need to be judged from exporting after selecting the output sharpening e.g. for glossy paper, if printing or screen sharpening for web images or emailing.
    The idea with sharpening is to apply capture sharpening so that the image in Develop looks just sharp but not over sharp. Lightroom then uses the correct algorithm for output sharpening based upon image size and quality settings etc.

  • Why do documents shrink when going from Pages To Word?

    To work on my Word docs on my iPad, I email them to myself, and save the attachments in Pages. To get them pack to my laptop, I email them back to myself from the iPad, as Word docs. The attachments that come back are half the size of the original (in KBs), even though I do not remove any content, and usually have added some. Does anyone know why this is, and what occurs to reduce the document to half the KBs it was before?
    Thanks.

    The content is text only, being composed in Word and edited in Pages. It's getting incoporated into a bigger Word document (the master document). I worry that a document which goes from 100 KB to 40KB is missing something - and that it will somehow corrupt the master document if I add it in.
    Pages takes .docx docs and saves them as .doc. But converting them back to .docx in Word after they've been compressed doesn't bring them back to their original size.

  • How can a user scroll the resultset obtained from a servlet in a jsp page?

    Actually i am having a page where user has to select company name and for tht i am providing him with a button, and on clicking tht button a
    new search page is provided , and on mentioning the search criteria ,a servlet is fired which returns a list of companies(tbasically i am creating a session object of resultset type which stores the companies name), now the servlets again goes back to search page, and here i want 2 display the company names, i am able to display company names in my search page , but now i want my user to select one of the companies from tht servlet.
    for tht i need to tap the onMouseOver function of java SCript, C
    Can any one tell me how to write code for tht
    Thanking in Advance

    see https://addons.mozilla.org/en-US/thunderbird/addon/send-later-3/

  • Trouble forwarding request from a servlet to a JSP in OAS 4.0.8.1 on NT

    The OJSP release notes state that:
    "Servlets and JSP cannot coexist as the same application" and "Requests cannot be passed between two separate applications."
    Does this mean that my attempts to use the
    the servlet RequestDispatcher to forward a request to a JSP are futile? If so, is this a problem that will be fixed in the future? I would like to use this feature!
    This is the code (based on a sample from Sun's JSWDK 1.0.1) that doesn't work:
    servletToJsp.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class servletToJsp extends HttpServlet {
    public void doGet (HttpServletRequest request,
    HttpServletResponse response) {
    try {
    getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/hello.jsp").forward(request, response);
    } catch (Exception ex) {
    ex.printStackTrace ();
    I am able to use the <jsp:forward page="/servlets/servletToJsp" /> directive to go from a JSP page to a servlet (across two OAS Applications) and I also can forward a request via the dispatcher from one servlet to another in the same OAS application.
    Any help in this area would be appreciated. Thanks.

    I'm using OAS 4.0.8.1
    You mean servlet to JSP does not work and JSP to servlet works for you????Yes - but I've only tried very simply examples.
    That's different from my understanding. If you are using OAS 4081, both cases should not work.
    The problem you mentioned will be fixed in future release of OAS.That's good to know - thanks!
    null

  • Executing an executable from a servlet or a JSP

    Is it possible to call an executable from a servlet. Say I have a client server application and I want to start the client application from a servlet. What is the best way to do that?
    I know normal Java applications can use the Runtime to run an executable. Can a servlet do the same? What are the security implications, considering that the servlet will be accessed from a browser?
    Thanks for your help.

    A servlet is executed on the server, not the client. The client receives a response from the servlet which is usually plain text formatted as HTML and/or javascript.
    So can a servlet use the Runtime class? Sure, but on the SERVER, not on the client. Hence, the executable will need to be on the webserver, not on the client machine and it will execute on the webserver, not on the client.
    Maybe, your HTML formatted response can include an <applet> tag to trigger the browser to download an applet that may have access to call an executable. Maybe a trusted applet?

  • Session attribute is lost while going from one action to other action

    Hi All
    I am working on struts application. The problem that I am facing is my session attribute is losing. I am doing following steps.
    1. Setting some values in ActionForm (note this action form is in session scope for each action using it) from homepage.
    2. then submit the form and go to searchation.
    3. perform some task and set some values on actionform.
    4. click a link and get back to homepage using homeaction.
    5.change on value on homepage and again perform step -1.
    till step 4 value is retained fine but as soon as we perform 5th step the values got lost.
    please if anyone can expalin why is this happening ( I am using get method on homepage.jsp)

    Hey if someone can help me

  • Lost finger print access when going from vista to xp

    Starting session with finger print worked fine with vista but after tranfering to xp pro I get a message saying the computer name is incorrect. Any solution?
    François

    François, welcome to the forum,
    did you delete the finger print profile in Vista before you installed XP?
    Try clearing the finger prints in the BIOS Security menu. You will then need to create a new profile from scratch in Vista.
    Hope this helps
    Andy  ______________________________________
    Please remember to come back and mark the post that you feel solved your question as the solution, it earns the member + points
    Did you find a post helpfull? You can thank the member by clicking on the star to the left awarding them Kudos Please add your type, model number and OS to your signature, it helps to help you. Forum Search Option T430 2347-G7U W8 x64, Yoga 10 HD+, Tablet 1838-2BG, T61p 6460-67G W7 x64, T43p 2668-G2G XP, T23 2647-9LG XP, plus a few more. FYI Unsolicited Personal Messages will be ignored.
      Deutsche Community     Comunidad en Español    English Community Русскоязычное Сообщество
    PepperonI blog 

Maybe you are looking for

  • Camera Raw Update for Nikon D800

    Does anyone know if there is a camera raw update for the new Nikon D800 in iphoto 08 version 7.1.5 and Aperture 2.1.4?

  • Unable to download Adobe Reader - Drwatson postmortem debugger problem

    I am trying to download Adobe Reader.  When I click the Download now - - I get the following message:  Website wants to install the following add-on  Adobe DLM. If you trust the website and add-on and want to install it , click here.   I click the me

  • CIS 8.0.0 and WSAD 5.1.2 (Websphere Server Application Developper)

    Hello, I'm trying to deploy CIS Server 8.0.0 inside Webphere Server Application Developper 5.1.2 running a Websphere Applcation Server 5.1 I'm deploying it following the cis-intallation-guide but the can't manage to start the server. I got a stacktra

  • PRELIMINARY_POSTING_FB01 when I_XCMPL is set to 'X' document is posted

    Hi All, When I am trying to park documents using PRELIMINARY_POSTING_FB01, the document is posted when I set i_xcmpl = 'X' but if I am right it should park the document as if we 'SAVE AS COMPLETED' say in FV60 i.e with status Completed. I tried loads

  • Owc_lcs.zip location?

    Greetings, im trying to integrate my webcenter portal with instant messaging, but first i need to locate a file called owc_lcs.zip that is inside middleware companion cd... i dont have such cd, i only have the middleware installer that is 1 file and