Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

how is the flow in this JSP

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Sheriff
Posts: 67583
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Soory to say that, I still did not understand how the request becomes POST
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That's what the method attribute is for that I mentioned.

 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic