| Author |
directives vs actions
|
Rauhl Roy
Ranch Hand
Joined: Aug 01, 2006
Posts: 401
|
|
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
Joined: Nov 16, 2005
Posts: 502
|
|
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.
|
Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />prabhu.venkatachalam@gmail.com
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
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 ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: directives vs actions
|
|
|