aspose file tools*
The moose likes JSP and the fly likes how is the flow in this JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how is the flow in this JSP" Watch "how is the flow in this JSP" New topic
Author

how is the flow in this JSP

Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
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

Joined: Jan 10, 2002
Posts: 61648
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
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
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
The first time the page is accessed it would be through a GET, not a POST, so the whole code block isn't executed.


Ping & DNS - my free Android networking tools app
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
But when is the page loaded for the second time
I mean to ask when and how??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
That happens when the form is submitted - since the form tag has no action attribute, it submits to itself.
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
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
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
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

Joined: Oct 04, 2009
Posts: 143
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
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
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

Joined: Oct 04, 2009
Posts: 143
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

Joined: Oct 04, 2009
Posts: 143
Soory to say that, I still did not understand how the request becomes POST
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
That's what the method attribute is for that I mentioned.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how is the flow in this JSP