Meaningless Drivel is fun!*
The moose likes JSP and the fly likes directives vs actions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "directives vs actions" Watch "directives vs actions" New topic
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: directives vs actions
 
Similar Threads
Pg 568 19thQues more doubts???
p590 - jsp:invoke
JSP directive
Valid Directives and standard actions with Tag files.
JSP or JSPF