Web Server passes control to JSP page?

I don't understand how the following is possible, but apparently it is.

My test situation:

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

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

upload.jsp
--------------
<%  
  if(request.getContentLength()) > 1) {
     pageContext.forward(....);
  }

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

check.jsp
----------------
<%= 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

elmoredanielAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

  if(request.getContentLength()) > 1) {
     pageContext.forward(....);
  }
elmoredanielAuthor Commented:
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!!
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
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.
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

elmoredanielAuthor Commented:
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.
borislavmarkovCommented:
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 ?
elmoredanielAuthor Commented:
Yes, of course I have the enctype right. Yes, the file uploads. Yes I know what I'm doing!
elmoredanielAuthor Commented:
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.
GranModCommented:
PAQed with points refunded (250)

GranMod
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.