Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Including a JSP Fragment with JSTL code in it

 
Peter Velosy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Forum members,

I've run into the following problem, and although I have tried googling and searching through the forums, I didn't find an appropriate answer.

My problem is as simple as this:

I would like to include the following segment in many JSP pages, which displays a login link if the user is not logged in, and a logout link with the username if he is already logged in.



I've put the @taglib directive here too for safety reasons, but it's also there in the page where I'm trying to include this segment with:



However, the main JSP page just reads my JSPF line by line instead of parsing the JSTL code included in it. How can I change the code, so that the JSTL Choose actually gets parsed?

Many thanks,
Peter
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rename the file to .jsp. The .jspf file type should only be used with the include directive, not the include action.
 
Peter Velosy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, it works! I didn't know about this difference.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65110
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Welcome to the Ranch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic