Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reusing the jspf  RSS feed

 
Srikanthh Ar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have the below sample jsp page.



and a static jspf page header.jspf




so when i do this i get an error in jspf page "date cannot be resolved"
i wish this header.jspf static page to be used in all my jsp files
so that the current date will be displayed in the page header.


can any one help me to resolve this date error which i am getting.
if the above scenario is wrong then help to have a static page header
for all of my jsp's
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using Java code in JSPs is a poor practice that has been discredited for almost 10 years now. Time to move on...

If you want to include common code in multiple JSP pages, you might want to investigate creating your own custom tag to do so. If the content is predominently markup, a tag file makes this almost trivial.

With regards to this specific example. instantiating a Date instance can be done without Java code via:and then used on the page withor, if you need it formatted
 
Srikanthh Ar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. Thanks.

Can you tell where i should use this useBean and the EL statements.
So that i can make it as a static content for all my jsp page.

Also can you clear whether i can use jave codes in jspf.
that is by using JSP scriplet/declaration.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java code (not "jave codes") should be used nowhere in JSPs, including fragments.

If you need something executed at the beginning of each JSP in the app, you should configure a prelude. See the JSP Spec for details.
 
Srikanthh Ar
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
Sorry for the java typo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!