Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java servlet / JSP assistance needed!! 1

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hey guys!

Can someone please explain this to me:
pageContext.removeAttribute("dbcon",PageContext.SESSION_SCOPE);

"dbcon" is a JavaBean created by myself, and my scope is "application" NOT "session"... s-)

This piece of code is from an example from a book and I tried to make it suitable for my project (which includes connecting to a DB).

Thanx for your help...

frag patrick.metz@epost.de
 
Uhh... almost forgot... there is a second issue:


<jsp:useBean id=&quot;dbcon&quot; scope=&quot;application&quot; class=&quot;com.dresdnerkw.supportcall.DatabaseConnection&quot;>
<% session.invalidate(); %>
<jsp:forward page=&quot;LoginView.jsp&quot; />
</jsp:useBean>


The <jsp:useBean> tag is perfectly fine. But why hasn't the tag been closed and WHEN is the code inside of it processed?
I don't find anything about this in any API's!!

Thanx for your patience!

frag patrick.metz@epost.de
 
The code between the usebean tags gets executed IF there is anew bean created, i.e. if no existing bean with the same id and scope is found
 
Thanx for your reply!

Let me see if I got this right:
The tag creates a new instance of &quot;DatabaseConnection&quot; and
if there is already an instance with the same ID it will kick it out of the memory and shot a forward to the LoginView-page ??

bye

frag patrick.metz@epost.de
 
no frag,

if an object named &quot;dbcon&quot; already exists in the &quot;application&quot; scope, no other object is created and the code between the <jsp:useBean > tags will not be executed.

manu0
 
Thank you manu0!

So, I'll have to use this tag for every JSP-page in my project if I want to redirect to the page &quot;LoginView.jsp&quot; (if no &quot;dbcon&quot; object is present)!?!

This helped a lot guys!!!
Sorry, just forgot to give a vote to all of you. :-(

cya

frag patrick.metz@epost.de
 
hello friends,
i am making a simple registeration form in jsp.
after checking username & password i want registered user should be forwarded to &quot;welcome.jsp&quot; while invalid users to &quot;invalid.jsp&quot;.
but the problem is that all the checking of username and password takes place in scriplets and <jsp:forward> cannot be embedded into it.
can anybody suggest a method to do it
any help will be appericiated
thanks

saddy

 
response.sendRedirect(&quot;invalid.jsp&quot;);

? --
Tim <tim@planetedge.co.uk>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top