Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

terminate a JSP page

 
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.
 
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.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic