Saving Vector  in session problem

Hi,
Im trying in my servlet to save vector into session and then retrive it:
// new vector
Vector VTree = new Vector();
// session
session = request.getSession(true);
//here I add some elements into vector VTree
VTree.size() // now using method size() I get number>0, so vector is not empty
// saving vector into session attribute SessionTree
session.setAttribute("SessionTree",VTree);
// then I clear vector VTree
VTree.clear();
// and Im trying to get vector from session, still in the same servlet, same method (doGet)
VTree = (Vector)session.getAttribute("SessionTree");
// and result, VTree.size() returns 0...
VTree.size()
Please help me, Im not possible to find error or bad expression...
Thanks, Jan

There are no errors. That is how Java works.
//here I add some elements into vector VTree
VTree.size() // now using method size() I get
number>0, so vector is not empty
// saving vector into session attribute SessionTree
session.setAttribute("SessionTree",VTree);You save a reference to that Vector in the session. So both your class and the session have a reference to the same Vector.
// then I clear vector VTree
VTree.clear();So you clear the Vector object. It has no elements now. Both your class and the session have a reference to this Vector, which is now empty.
// and Im trying to get vector from session, still in
the same servlet, same method (doGet)
VTree = (Vector)session.getAttribute("SessionTree");Now you get the reference to the (empty) Vector from the session and assign it to a variable in your class. (Your variable already had a reference to that same Vector.)
// and result, VTree.size() returns 0...
VTree.size()Yes, it does. Because you cleared the Vector earlier.
Remember, assigning a variable doesn't make a copy of an object. It just makes a copy of a reference (like a pointer) to the object.

Similar Messages

  • Session problem in ADF BC

    We have an application developed in Jdev 10.1.3.4 (JSP, Struts, ADF BC) and running on OAS. Now we have a big problem with session, hope somebody can help with some ideas.
    We set session time to 45 min in the web.xml. The problem is that sometimes some user work on a page with form,for instance performing some edit activity. If he/she leave the page open inactive for more than 45 minutes and come back from lunch, press the ’save’ button, the application would then commit the change to the wrong row in database, most probably the top row in the View Object(VO) instance. This is because the application module actually does a rollback when session expires, it loses all user data.(e.g. row currency in VO instance).
    To avoid saving wrong data to the wrong place, we implemented a session Filter(see att. Below: ApplicationSessionExpiryFilter.java) to catch session time-out and forward request to an error page alerting user that their session has expired due to long time of inactivity. The Filter works as it should but it gives another problem. If user already has one of our application page open for very long time and open another page in a new browser (e.g. click a link from an email), he/she will get session-expire error immediately in the new browser. I guess it is because the session in the first browser already expires and the newly opened the browser shares the same session with the first one. That is how browsers works, we can do nothing about it.
    But our users are of course not very happy about getting the session errors in a newly opened browser. So we tried implementing a heartbeat funtion in AJAX(see att. Below: Heartheat.html and Template.jsp) to keep the session alive until the page is closed. Basically what we do is adding an invisible div tag in every jsp page and invoke AJAX funtion to periodically update the div tag with a small html page. In this way, a request is being sent to the server every 5 minutes thus the session should be kept alive until the page/browser is closed.
    It sounds to us like a very logical solution but it doesn’t work very properly. We sometimes still get the session error page immediately after opening a new page while we have another page open for long time.
    Could anyone please help to look at our Filter and heatbeat funtion? Is there anything wrong with our Filter or the heartbeat? Why does the session still expire before we close the page?
    All we do here is to try to avoid the initial probelm with saving data after session and the application module expires. If anyone has a better solution to this problem, we would very much like to try. Appreciate if anyone can share some ideas!
    Thanks in advance!
    *1. ApplicationSessionExpiryFilter.java*
    public class ApplicationSessionExpiryFilter implements Filter {
    private FilterConfig _filterConfig = null;
    public void init(FilterConfig filterConfig) throws ServletException {
    _filterConfig = filterConfig;
    public void destroy() {
    _filterConfig = null;
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    boolean sessionInvalid = false;
    if(httpRequest.getRequestedSessionId() != null) {
    if(!httpRequest.isRequestedSessionIdValid()) {
    if (!httpRequest.getRequestURI().endsWith("sessionExpired.do")) {
    sessionInvalid = true;
    if (sessionInvalid) {
    ((HttpServletResponse) response).sendRedirect(_filterConfig.getInitParameter("SessionTimeoutRedirect"));
    else {
    chain.doFilter(request, response);
    *2. Heartheat.html* (A small html page to be invoked by template.jsp periodically)
    <html>
    <head>
    <META Http-Equiv="Cache-Control" Content="no-cache, must-revalidate">
    <META Http-Equiv="Pragma" Content="no-cache">
    <META Http-Equiv="Expires" Content="Expires: Mon, 26 Jul 1997 05:00:00 GMT">
    </head>
    <body>
    heartbeat to keep session alive!
    </body>
    </html>
    *3. Template.jsp* (Template page to be extended by all jsp pages, invoke heart.html every 5 min)
    <Html>
    <body>
    <div id="heartbeat" style="display:none">
    </div>
    <script type="text/javascript" language="javascript">
    new Ajax.PeriodicalUpdater('heartbeat','jsp/template/heartbeat.html',{ method: 'post', frequency: 300, decay: 1 }); // update heartbeat.html every 300 sec(5min)
    </script>
    </body></html>

    Hi Shay,
    Reviewing ADFContex methods it seems that this object shouldn't be accessible from BC. Example:
    public static ADFContext initADFContext(java.lang.Object context,
                                            java.lang.Object session,
                                            java.lang.Object request,
                                            java.lang.Object response)
        Initializes the ADFContext for the environment of the specified context.
        Parameters:
            context - the ServletContext or PortletContext of the current execution environment.
            session - the HttpSession or PortletSession of the current execution environment. OPTIONAL.
            request - the HttpServletRequest or PortletRequest of the current execution environment. OPTIONAL.
            response - the HttpServletResponse or PortletResponse of the current execution environment. OPTIONAL.
        Returns:
            the ADFContext that was current when init was invoked. Should be passed back to resetADFContext after the block requiring the ADFContext has completed.Kuba

  • Session problem in one out of two jsp

    Dear java guru's
    I have got jsp page A.jsp.User select few option and this jsp calls
    B.servlet this takes user input and pass to
    C.bean which returns vector to B.servlet
    This servlet put vector in session and dispatch to new jsp
    D.jsp which calls
    E.jsp in it for Image generation.
    This E.jsp retrieve vector from session and generate a image and reurn to D.jsp
    Now my problem is that session in B.servlet and D.jsp are same but a new session in created in E.jsp so image is null as it could get data from vector which is null.
    I put System.out.println(session.getId()) in each servlet and jsp so to get thier ID's.
    This is working fine in my system with Tomcat 3.2 but on web the new session is created for E.jsp
    I am calling E.jsp like this
    <img src=<%=response.encodeURL("/iscap/report/jspChart.jsp")%> alt="generation image" width="400" height="350" border="1">
    I am making page session=true in each jsp and also puttting request.getSession(false);
    but still E.jsp is getting new session.I tried eliminating each one and made all combination that could be possible but not effect.
    How Can I solve this problem on the web where I have to load this?
    Do I have to make setting in context .
    payal sharma

    Hi,
    If you have been using jspChart v 1.00 :
    As shown in the modified , attached PPT :
    I will be displaying a bar chart. The length of bar chart is obatined from Sybase database. This chart should be dynamically created depending on the value on
    the database and x -axis is exponential.
    This will be displayed on a HTML page.
    1. I want to know whether,the values can be obtained the values from Sybase database ?
    If so, what are the changes.
    2. can you tell me the steps to install and run the jspchart v 1.00 on Jrun or any server please.
    Any thing else, I need to install like SAX , JCLARK. I am getting errors in this. PL HELP.
    3. Is it possible to plot "Exponential values" in the Y-axis. like 0 - 100- 1000 - 10000 - 100000
    and the length of the Bar should automaticall be coloured till that Point as shown in the Power point attached.
    If not, any suggestions to use any other software.
    Thanks in advance.
    [email protected]

  • Vector in session

    Hi
    I am passing vector in session between two jsp's
    In the first jsp I have
    session.setAttribute("serialnumber_Vect",serialno_Vect);
    In the recieving jsp I have the following
    Vector serial_Vect = (Vector)session.getAttribute("serialnumber_Vect");
    But i am not able to see the values in the receiving jsp
    what is the problem
    Thanks
    Arn

    did u set your scope to session?

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • The Query Could not be saved due to a problem in Transport

    Hi All,
    we move the data from DEV to QAS but in the QAS when you are going to save as query giving this error
    error: The Query Could not be saved due to a problem in Transport  
    can any one please tell me the solution for this
    thanks
    sidhartha

    Sidharth,
    When you create a transport request for queries in Transport connection, what is the grouping condition you have taken and also please be ensure that all the query elements have to be selected to transport that query.. Please check whether all the elements have been selected or not.. You can check this out in SE09 under your request.
    Hope this helps...
    ****Assign Points****
    Thanks,
    Gattu

  • Session problem in jsp application

    I face a session problem. I setting everything in a session and when pass back to a main page, the value is not display in the screen. But after refresh the value will display in the screen and this kind of problem only come out very few time and i dun knw how to solve this...
    Anyone here can give me some idea and suggestion or the way to solve this kind of problem!!!

    define "2 different clients"
    1) You have 2 different PCs and it's using the same session ID for both? I doubt this. I think the server is advanced enough not to use give a session ID that's already been created.
    2) You have 1 PC and are using IE or Netscape and using File > New Window to open a new window and connect again. This you can't fix without using only URL rewriting to manage session, because the different windows will share the same session cookies.

  • JSP Session Problems

    Hi, i am facing a problem of the Object set into a session not being visible to the others pages. what did i done wrongly?
    here is the code:
    in login.jsp (currently hardcode cos i haven recieve that part):
    <%@page import="fantasy.team.*,java.util.Vector" session="true"%>
    <%
    Team t = new Team("Kacheek FC");
    session.setAttribute("team",t);
    if( session.getAttribute("team") ==null){
         out.write("how come null");
    }else{
         out.write("not null");
    %>
    Select
    //End of coding
    not null will be printed
    Following code belong to selectPlayer.jsp:
    if( session.getAttribute("team") == null){          
              out.write("i am null");               }else{
              out.write("i am not null");
    i am null is printed
    what is wrong with my coding?
    thanks.

    i do a
    if(session.isNew())
    out.write("New");
    and the result is new.
    meaning that my session is invalidate.
    that explain my value from "gone" rite?
    how to solve this?
    thanks.

  • Illustrator CS4 saving vector art for Microsoft Word

    I have a logo created in Illustrator CS4. I saved the file for use in Microsoft Office using the "save for Office", exporting as a .wmf, and even saving the vector art in Photoshop as a .png. I can get a variety of formats to work well in Word documents.
    Here is the problem. The Word document will eventually be saved as a PDF. When the file is saved as a PDF document (from Word), the color is changing in the PDF file. How can I correct this? I've tried saving in both rgb and cmyk color modes, but the color changes once it hits Acrobat and is printing differently than the Word file. It is driving me crazy and I cannot figure this out.
    Thanks for any help!
    Mary

    The type is not vector it is raster it is no longer outline.
    Check to see if you can select the individual letters in AI if you cannot it has be rasterized and is an image not vector.
    If you open my files you will see that they are selectable in Acrobat and AI.
    You seem confused and I do not understand why.
    Attached is a word file with vector art and type make a  pdf from that and see the difference.
    Also make certain you have Illustrator editing capabilities turned on when exporting to pdf from AI.
    Can you attach one of the eps or the esp you made the sample file from.
    Do not rasterize the outline text art.
    It won't let me attach a word document.

  • Ps CS5 vector shape redraw problem

    So I use vector shape layers a lot where I feather the edges to make shadows and what not; I also place layer masks on them.
    The problem I'm having is that when I move the shape around in the document, most of the time the image stays where it was originally and doesn't update to the new location.  That is unless I click on the vector mask, move it back and forth, and turn the layer mask on and off – only then does it update to the new location.
    I hope this makes sense, but if not ask away.  I didn't see any other threads regarding this issue, but if I missed it please redirect me.
    Thanks!
    I'm running Ps 12.0.4x64 on a MacBook Pro – OSX 10.7.2 – 2.3GHz Core i7 with 8GB RAM.  I've had this problem on two other Macs as well.

    Boilerplate-text:
    As with all unexplainable Photoshop-problems you might try trashing the prefs (after making sure all customized presets like Actions, Patterns, Brushes etc. have been saved and making a note of the Preferences you’ve changed) by pressing command-alt-shift on starting the program or starting from a new user-account.
    System Maintenance (repairing permissions, purging PRAM, running cron-scripts, cleaning caches, etc.) might also be beneficial, Onyx has been recommended for such tasks.
    http://www.apple.com/downloads/macosx/system_disk_utilities/onyx.html
    Weeding out bad fonts never seems to be a bad idea, either. (Validate your fonts in Font Book and remove the bad ones.)
    If 3rd party plug-ins are installed try disabling them to verify if one of those may be responsible for the problem.
    Does turning off OpenGL in the Performance Preferences and restarting Photoshop have any bearing on the issue?

  • Illustrator saving vectors with different attributes than assigned prior to saving

    I am having a problem whenever I save a document in Illustrator.
    Near the edges of the page, I am placing a few rectangular vectors filled in only with black.
    When I save the image as a .pdf, two of these get changed.
    One on top, and one on bottom, at the exact same x placement.
    Prior to saving, they are all completely identical with the same attributes.
    I even deleted the old ones, replaced them with new ones, which I copied from other marks that were not messing up, and saved the .ai file as a .pdf again, but to no avail.
    Please help as I have no idea what to do to fix this.
    I have tried unchecking save as an illustrator editable file, save with layers, etc.
    Any advice would be greatly appreciated.

    BeeHiver wrote:
    Well, I believe that it is simply the way that adobe was displaying it, because if I zoom in on the .pdf file, the added thickness disappears.
    The same thing happens when I have the letter I in text, not sure why this happens, but I no longer think it is an issue.
    That letter 'l' looking thicker is a known issue with a PDF file... as you've noticed, it clears up when you zoom in and also, it doesn't print like that...

  • Save as EPS - Include Vector Data - Printing problems

    Hey everyone
    I'm having an issue with PDFs that I send to a specific newspaper and only them. The problem only occurs in the vector data that is saved in the EPS to be distilled.
    Here's an overview of my workflow
    *Build ad in Photoshop CS3
    *Save EPS with Preview:Macintosh(8Bits);Encoding: ASCII85; Include Vector Data; all other options not checked
    *Distill EPS to Press Quality PDF
    *Send to newspaper
    The problem looks like their RIP is choking on the vector data (primarily text) in the ad. It appears to start to print the text and then just stops or prints a bunch of garbage where the text should be.
    I have their in-house Distiller settings and use those now instead of Press Quality. This should rule out any problems with the Distiller settings.
    I send dozens of PDFs a week to multiple publications and only have trouble with this one. Is it possible that the "Preview" and/or "Encoding" in the EPS is the problem? Any suggestions what the bare bones settings should be for "Preview" and "Encoding" for the EPS? I want to keep the Vector Data b/c the outputted text remains crisp.
    Thanks!

    I agree with Mike.
    A lot of newspapers are not making a lot of profit and, as a result, may not have up-to-date RIPs. This is demonstrated by your statement that this is the only publication you have problems with.
    If your only concern is file size, know that either way, you're dealing with small files. Try the direct-from-Photoshop route with the paper and see what happens. Get the production guru at the paper to work with you on solving the problem.
    Also, what happens if you Distill the file as an industry-standard PDF/X-1a file. If you see that the file is compliant, you shouldn't have a problem.
    Neil

  • Session problem in a new window created by window.open()

    hello,
    I have a drugsearch.jsp page, I sessioned an durgCollection object on this jsp page using session.setAttribute("drugCollection",drugCollection);
    there is a link on this jsp which will call a javascript to open a new window .
    here is the javascript to open another new window:
    function openReportWindow()
    window.open("/drug/Report.jsp","report", "toolbar,scrollbars,width=800,height=800,left=100,top=10");
    but in the Report.jsp, I won't be able to get the same session object as in the calling jsp ( drugsearch.jsp) by calling session.getAttribute("drugCollection").
    if I change the link on drugsearch.jsp to link to the Report.jsp directly instead of opening a new window, then I can get the same session object from the Report.jsp.
    what's the problem? can someone give me an advice?
    thanks

    A session is assosiated with one client(browser).
    when you open a new browser, a new session is created. In order to have common place for both the browsers, try storing the data in the 'Servlet Context'

  • Image will not change on the Browser...Saving on the Tomcat Problem...HELP

    Hi,
    I worte a Servlet project using JBuilder 7 and TOmcat 4. THis is basically what i am doing...
    I am getting an image from database and saving it to a folder in tomcat and then displaying it on a browser.
    This application is used by multiple users...
    I am saving the Image in Tom-cat...C:\JBuilder7\jakarta-tomcat-4.0.3\webapps\examples\Image1.jpeg
    I am also displaying the image from that folder. The problem is when i run the application,
    I am seeing the same Image on the screen..Its creating the different Image file, but the image is the same.
    If i do a refresh on the page then it displays the new saved Image...
    Also, If i save the image on my local and then display it from my local it changes the images as I
    click on a Image list...
    Following is how it works when i save it and display it from my local, but if i run my application from
    another computer i am not able to see any of the images....Because its on my local.
         fos = new FileOutputStream("C:/Image1.jpeg");
         <img src="file:///C|/Image1.jpeg" height="855" name="myimage" align="middle" style="position:absolute;">;
    And this is how i am doing when i am saving to the tomcat....I am able to display it on another computer
    but would not change the image...
    fos = new FileOutputStream("../webapps/examples/Image1.jpeg");
    <img src="../Image1.jpeg" height="855" name="myimage" align="middle" style="position:absolute;">;
    Can some one please tell me what could be the Problem....
    Any help will be greatly appreciated....Thanks...

    The browser caches images so that it doesn't have to always download the same image for different pages.
    You could:
    1: Save the new image with a different name and dynamically change the name in the html.
    2: Try setting the response headers to prevent the browser from caching the images.
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);

  • Urgent: Sessions problem pls help me

    Hi all,
    Its already late to post this problem.pls help me urgently.
    I have a servlet & two jsp's. first i request servlet, it processes something and forwards request to my first jsp. In that jsp on a button click, i'm displaying a new popup by calling showModalDialog. this dialog gets data from the same servlet but it forwards to my second jsp.(second jsp can be seen in dialog)
    Now if i submit form from my second(dialog) jsp, the servlet reports that session has expired. I tried a lot but invain. any one who helps me is appreciated well by all of our forum.
    waiting 4 u r reply,

    It could be that you have cookies turned off and you're not using URL Rewriting.
    In J2EE, the first time your browser makes a request to the server, the server responds and appends a SESSION_ID parameter to the request as well as storing a cookie with the SESSION_ID.
    The second time your browser makes a request, the server checks for the cookie. If it doesn't exist it checks for the parameter. If neither exist the server assumes its the first time your browser has made a request and behaves as describe in the previous paragraph.
    In your case when you submit the form if you have disabled cookies and the action attribute doesn't have the SESSION_ID paramter appended to the url, the browser will assume it's a first request. The user will not be logged in, hence your session has expired error.
    To fix this you need to encode the URL in your JSP. You can use the struts html:rewrite tag or the HttpServletReponse.encodeURL method, or if you're using JSP 2.0 the JSTL c:url tag.

Maybe you are looking for

  • Shell program and XML Publisher E-Text Template

    Hi All, We have a customer submitting an rdf report through Shell script using the command line submission ar60run. This is being done in 11i. This rdf handles the File transmission with certain codes for the third party(same as E-Text templates in R

  • I update iTunes from 4.8 to 5.0 and now it wont open!

    I get this microsoft error: iTunes has encountered a problem and needs to close. We are sorry for the inconvenience. I have tried reinstalling/repairing but that doesnt work. This has benn coming up for a week now and I really want it fixed.

  • Download adobe flash player addon

    adobe flash player doesn't download from http://get.adobe.com/flashplayer. it stops midway and does not respond with neither through firefox nor through bit comet.

  • The arrays class question

    consider the code below int[] list = {2, 4, 7, 10}; java.util.Arrays.fill(list, 7); java.util.Arrarys.fill(list, 1, 3, 8); System.out.print(java,util.Arrays.equals(list, list));i understand line 2, it gonna fill 7 into the array,so the output would b

  • TestStand ActiveX control compile warnings in WPF 2012

    hello everyone, I am using TestStand ActiveX controls(ApplicationMgr, SequenceMgr, ExcutionMgr) in my project written in WPF 2012. After I put the controls on the form, there are some referrences automatically included in my project. But when I compi