Web Server passes control to JSP page?

Posted on 2006-04-11
Last Modified: 2010-04-01
I don't understand how the following is possible, but apparently it is.

My test situation:

<form action="upload.jsp" ...>
<input type="file" ...>

I loaded the input with a very large file, then hit submit.

  if(request.getContentLength()) > 1) {

  session.setAttribute("testvar","I should not exist until the file upload is received.");

<%= session.getAttribute("testvar") =>

I ran check.jsp right after I hit the submit button. And the session var "testvar" existed immediately, it did not exist before I hit submit. How is this possible? The upload.jsp did not "run" because it would have redirected the request, yet it did "run" because it set the session variable. I have tested this a variety of different ways and yeilded the same results.

~I am very confused

Question by:elmoredaniel
    LVL 12

    Expert Comment

    ...not neccessarily, are you sure your condition was met?  And could you explain it?

      if(request.getContentLength()) > 1) {

    Author Comment

    It doesn't matter. I can take the if statement away and just have it forward immediately and I get the same results. Seriously this is weird, try it!!
    LVL 23

    Expert Comment

    Just try running the same thing after you have restarted the server i think it must fail, as such i am not sure.

    In previous case i think your session was yet maintained so only it might have happened.

    Just try & get Back.

    Thank you.

    Author Comment

    shivaspk, good thought. I found that as long as the session scope has been initialized (by setting any attribute in it) then the strange scenario still exists. Which futher makes this more confusing.
    LVL 2

    Expert Comment

    when uploading a file your enctype of form should be set.

    >>    <form action="upload.jsp" ...>

    What do you have instead of "...", do you have enctype, so browser send the file correctly?
    Do you upload the file correctly ?

    Author Comment

    Yes, of course I have the enctype right. Yes, the file uploads. Yes I know what I'm doing!

    Author Comment

    borislavmarkov, I apologize for my seeming tactless response, and here's the answer to the question for future visitors.

    The web server does indeed pass the full request to java server and begins processing the page, at least with the  configuration I have (IIS -> JRun). The problem is, the browser is clueless about what's going on. It must continue to ship the data upward, then it can respond to any "queued" responses.

    Accepted Solution

    PAQed with points refunded (250)

    Community Support Moderator

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now