Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

you are not logged in

Thread view: 
gk - 12 Feb 2006 16:00 GMT
i am giving a real example.

do you use ebay or any online e-commerce portal.

there you can see a search box. in that search box , you can search for
any items . you get a result page and for each item, you get a "Bye
now" button next to it.

but as soon as you are trying to buy , you'll be getting a prompt for
login page . after your login, you again go back to the same page.

my question is, how we can go back to same page ?

i have a guess for coding..

when a user clicks for "Bye Now", the code checks whether use==null or
not. if(user==null) then response.sendRedirect(/login.jsp) and when the
user logs in what the code would do ?

you know these kind of sequences could arise.

1. user come to site and logs in

2. user did not login first but go for searcing items and then go for
"Buy Now", now he should login and get back the similar page.

its very easy if the user follows step(1)

but How do i code if the user follows step(2) because in that case , he
has to get back the page as soon as he logs in.  and  how do i know
,whether user is coming via step (1) or via step (2) ? if he comes via
step (2) how do i code ?

thank you
Ian Mills - 12 Feb 2006 17:10 GMT
> i am giving a real example.
>
[quoted text clipped - 30 lines]
>
> thank you

I would think you would keep track of whether the user was logged in in
the session and when a function is called that requires the user to be
logged you would check in the session if this was so and act
accordingly. This means it does not matter which sequence to user takes.
This would also make it possible to force the user to log back in after
a period of inactivity as the session would have timed out.
gk - 13 Feb 2006 04:28 GMT
yes.

but, say user is not logged in.

user-1 trying to access page1.jsp ==>he gets a login prompt ==>he logs
==>he gets back  mypage1.jsp .

user-2 trying to access page2.jsp ==>he gets a login prompt ==>he logs
==>he gets back  mypage2.jsp .

user-3 trying to access page3.jsp ==>he gets a login prompt ==>he logs
==>he gets back  mypage3.jsp .

so, you see, how difficult it is to track the pages to give back as
soon as the user logs in. because every time user is demanding new
pages.

so if there are lots of pages then its dificult to handle it.
gk - 13 Feb 2006 04:44 GMT
please clarify you comments

you told ".....whether the user was logged in in
the session and when a function is called that requires the user to be
logged you would check in the session if this was so and act
accordingly......"

whats the code ?

here i am postng  the code..but this does not work.

String user = session.getAttribute("user");

if(user==null) response.sendRedirec(/login.jsp)
else
{
// display all the search items here.
}

Now, think,  the user==null, and so he is going to the login page by
"response.sendRedirec(/login.jsp)"  . now  the user logs in there. how
does he get back the previous page !!!!

whats the code i have to write now to get  back the previous page ?
Ian Mills - 13 Feb 2006 19:52 GMT
> please clarify you comments
>
[quoted text clipped - 20 lines]
>
> whats the code i have to write now to get  back the previous page ?

You could possibly keep track of the next page to go to in the session -
so if the user logs in initially this would be balnk so send him to the
start page otherwise befor doing the re-direct save the page the user
was trying to go to in the session and then redirect to the login page.
Now when the user logs in this parameter would be set so then you could
send another e-direct to go to the required page.
gk - 14 Feb 2006 12:09 GMT
I
the re-direct save the page the user
> was trying to go to in the session and then redirect to the login page.
> Now when the user logs in this parameter would be set so then you could
> send another e-direct to go to the required page.

you told "save the page "

did you mean saving the name of the page ?
like this

session.setAttribute("pageToAccess","mypage.jsp")

and again ,
when he user logs in i should retrieve this way,

String pagetoaccess=session.setAttribute("pageToAccess");
response.sendRedirect(pagetoaccess);

is this kind of code you are offering ?

please clarify.

thank you
Tim B - 13 Feb 2006 05:22 GMT
> i am giving a real example.
>
[quoted text clipped - 14 lines]
> not. if(user==null) then response.sendRedirect(/login.jsp) and when the
> user logs in what the code would do ?

one way to accomplish this is to append a parameter to the url when
redirecting that indicates either the page the user started at or their
search criteria that was used when displaying their starting page. Put a
hidden field with this value in the login jsp, so when it  is submitted to a
servlet or whatever, logic can be done to redisplay the original page to the
user. This appears to be how ebay does it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.