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

terminate a JSP page  RSS feed

 
eric zhao
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks:

jsp1 has a return statement at the end. Then I include it on top of jsp2 with:

<jsp:include page="jsp1" flush="true"/>

Now jsp2 still displays even though jsp1 has a return statement! Why is that? I tried it on JRun and Tomcat inside JBuilder.

I am trying to write jsp1 as a common security check jsp, so it returns if user doesn't have the right role. Then I can just include it on top of every page that is not for regular user. However, it doesn't work :-(

Help? Thanks.
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you mean by a return statement in JSP. If you could elaborate then it would help.
However I can suggest an approach to achieve what you want. Try as follows:
Use a single logon screen at start of app.
Store the security info in a bean in session.
In all jsp's read the session bean and validate the user.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65830
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"DKT",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
[ July 14, 2005: Message edited by: Bear Bibeault ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by eric ontario:
Folks:

jsp1 has a return statement at the end. Then I include it on top of jsp2 with:

<jsp:include page="jsp1" flush="true"/>

Now jsp2 still displays even though jsp1 has a return statement! Why is that? I tried it on JRun and Tomcat inside JBuilder.

I am trying to write jsp1 as a common security check jsp, so it returns if user doesn't have the right role. Then I can just include it on top of every page that is not for regular user. However, it doesn't work :-(

Help? Thanks.


You may want to read up on the difference between <jsp:include...
and <%@ include....

In a nutshell, the first being the JSP Include action, runs both JSPs and merges the output at runtime.
The second, being the JSP include Directive, merges the JSP code at compile time.

Since you're using the JSP include action, your included page is being run, and stopping at your "return" statement. The output is inserted into the output stream. Then the outer page continues.
[ July 14, 2005: Message edited by: Ben Souther ]
 
eric zhao
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, Ben. I got it completely wrong between the <%@ include> and <jsp:include>.

Thanks.

eric
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!