Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

directives vs actions

 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

directives are said to be static things. That is, those get included at the compile time with thie actual JSP page. And they work as if they are just Pasted in the actual JSP page.

And JSP Actions are done/ happen at runtime.

Here my doubt is that, if I declare a varible in page directive and use it at runtime what will happen?

And the other thing is that, Can the declared variable in a directive be chaged dynamically or at runtime?

Supposed int a =4; is declared in diretives


what will happen if I use for loop to print int a according to my wish?

thanks in advance
rahul
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how will declare a variable in page directive? you cannot.

I guess you are talking about include directive.

Even you include another JSP file using include directive, it will copied into main JSP file at transalation time(JSP -> Servlet) not at compile time. So whatever variable you declared in included JSP still be avalible at runtime in main JSP.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming you're talking about the include action and directive, this FAQ entry might answer your questions:
http://faq.javaranch.com/view?IncludesActionDirective


Also, with all due respect...
Wouldn't it have been faster to write a little JSP test page to find this out than to write to a forum and wait for someone else to answer?
And the other thing is that, Can the declared variable in a directive be chaged dynamically or at runtime?
Supposed int a =4; is declared in diretives
what will happen if I use for loop to print int a according to my wish?

[ December 08, 2006: Message edited by: Ben Souther ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic