Strategy for log-in on web-site

A

Andrew Thompson

Strategy for log-in on web-site

Assuming I have a group of pages,
an index.jsp and (say) page1.jsp thru
page5.jsp.

The idea is that I want to ensure that each
visitor sees and agrees to a 'useage agreement'
before viewing _any_ of the pages
(irregardless of which page they surf in on),
and that particular pages had extra 'UAs'
(say ..pages 3 & 5) that have to be passed.

My first thought is to achieve this using a
JavaBean, adding that bean to the user's
session through each of the pages.

However, I'm new to server side, so
my question is...

Is that a good strategy, would a JavaBean
be the best way to ensure the desired
behaviour?
 
S

Sudsy

Andrew said:
Strategy for log-in on web-site
Is that a good strategy, would a JavaBean
be the best way to ensure the desired
behaviour?

Andrew,
It doesn't have to be that complicated. I just create a String
and stick it in the session. Each page checks whether on not the
String merely exists in session scope and redirects if it doesn't
find one.
 
A

Andrew Thompson

...just create a String
and stick it in the session. Each page checks whether on not the
String merely exists in session scope and redirects if it doesn't
find one.

Thanks Sudsy, sounds good.
 
A

Andrew Thompson

Sudsy said:
....
...I just create a String
and stick it in the session. Each page checks whether on not the
String merely exists in session scope and redirects if it doesn't
find one.

I didn't do a redirect, I simply include
different content depending on whether
the user is logged in.

I was also having trouble checking whether
the string _existed_. I didn't get that bit, if
I have to declare a String that carries across
sessions, I need to declare _it_ as a bean
don't I? In that case, it always exists, so
I assign a particular _value_ to the string
and check for that value (it seems to work).

Did I misunderstand you?

Having said that, is this (approximately)
what you meant?
http://www.physci.org/test/login/index.jsp

( You can see the .jsp source by clicking
the imaginatively titled 'Source' link. )

Are there any particularly silly things I have
done in it?
 
S

Sudsy

Andrew Thompson wrote:
I didn't do a redirect, I simply include
different content depending on whether
the user is logged in.

I was also having trouble checking whether
the string _existed_. I didn't get that bit, if
I have to declare a String that carries across
sessions, I need to declare _it_ as a bean
don't I? In that case, it always exists, so
I assign a particular _value_ to the string
and check for that value (it seems to work).

Did I misunderstand you?

Having said that, is this (approximately)
what you meant?
http://www.physci.org/test/login/index.jsp

( You can see the .jsp source by clicking
the imaginatively titled 'Source' link. )

Are there any particularly silly things I have
done in it?

Dude, you're going to have to start using tags! Scriptlets are
just so passe. I would check for existence like this:

<logic:present name="USERID">
....do some stuff here
</logic:present>

In the servlet I would do this:

public void doPost( HttpServletRequest req, HttpServletResponse resp ) {
HttpSession sess = req.getSession();
// if logon successful then
sess.setAttribute( "USERID", "" );

It maps similarly with struts.
 
A

Andrew Thompson

Sudsy said:
Andrew Thompson wrote: ......
Dude, you're going to have to start using tags! Scriptlets are
just so passe.

...I don't know. We didn't need such new
fangled things when _I_ were a boy.

I fact, come to think of it, we didn't have
computers when I were a boy.

[ I'll look into it, thus far, the mix of the
various html, Java and other different tag
styles is messing with my head.. ]

Thanks
 
S

Sudsy

Andrew said:
..I don't know. We didn't need such new
fangled things when _I_ were a boy.

I fact, come to think of it, we didn't have
computers when I were a boy.

[ I'll look into it, thus far, the mix of the
various html, Java and other different tag
styles is messing with my head.. ]

Thanks

Drop me a note off-line and I'll likely be able to dig up some
functional code which meets your requirements. But I agree that
it can become overwhelming at times...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,081
Latest member
AnyaMerry

Latest Threads

Top