Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how is the flow in this JSP

 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to understand the use of <c:url> tags, I looked for a example in here.
But i did not understand the flow of execution in this page at all
Could you please explain it?

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64692
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really not indent your code? If you do, why are you posting unindented code that's hard to read?

In any case, in the following:
The <c:url> action creates the properly formed and encoded URL and stores it in a scoped variable named url.

Afterwards, the EL expression ${url} causes it to be emitted into the generated HTML.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the unindented code. I indented it now.
But when the page is first loaded, only the table is created, and ON clicking the submit button the c:url thing is happening. I mean why is the curl thing not happening when the page is loaded(It would have printed null anyhow)?? what is THE condition that is stopping the execution of the c:url until the submit button is clicked.

May be this question is simple and stupid. I think this is because i don't have an prior experience in development
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first time the page is accessed it would be through a GET, not a POST, so the whole code block isn't executed.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But when is the page loaded for the second time
I mean to ask when and how??
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That happens when the form is submitted - since the form tag has no action attribute, it submits to itself.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:The first time the page is accessed it would be through a GET, not a POST

Ulf Dittmer wrote:since the form tag has no action attribute, it submits to itself.


What i understood from these statements is that when a from without action attribute is first loaded , it is GET. And when it is submitted it would return the same page with a POST request. (Correct me if i am wrong. i have a feeling that this is wrong.)
With the above assumption i tried this code in a JSP.


EVEN after submission the method returned is GET
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What i understood from these statements is that when a from without action attribute is first loaded , it is GET.

It has nothing to do with whether or not a form in a JSP page has an action attribute. Any URL entered in a browser is accessed via GET.

With the above assumption i tried this code in a JSP.

EVEN after submission the method returned is GET

You can't just randomly omit attributes and expect things to work still. If you want a POST, then you need a method attribute that says so. In the absence of a method attribute, the default method is GET.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:The first time the page is accessed it would be through a GET, not a POST, so the whole code block isn't executed.

Then how is the request becomes post when the form is submitted ??
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what the method attribute is for that I mentioned.

By the way, that smiley you're using doesn't mean what you think it means: http://faq.javaranch.com/java/SaloonGraemlins
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
By the way, that smiley you're using doesn't mean what you think it means: http://faq.javaranch.com/java/SaloonGraemlins

Oh... sorry i did not me that expression
i meant
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Soory to say that, I still did not understand how the request becomes POST
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what the method attribute is for that I mentioned.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic