User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 423,339 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 5,185 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 424 | Replies: 3
Reply
Join Date: Jun 2008
Posts: 1
Reputation: cleopatra789 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cleopatra789 cleopatra789 is offline Offline
Newbie Poster

Ambiguity in using the same jsp

  #1  
Jun 19th, 2008
Hi,
I m new to jsp and currently i m trying to fix this problem.

In my project, we have an enhancement where we are trying to access a changepassword.jsp 1) directly through URL 2)Invoking this jsp after loginhandler.jsp.

1) is for existing users. 2) is for new users.

We have seperate error codes for new and existing users.

The 2) option is working fine. Here a new user first logs in (into the loginhandler.jsp). His errorcode is recorded using setAttribute(). Then, he is shown the changepassword.jsp and here, getAttribute(errorcode) is done and then, the new user is allowed to change the password.

However, in 1) option, we are still using the same changepassword.jsp. As a result of this, when the code encouters getAttribute(errorcode), the logic fails since this jsp is directly accessed from URL and it doesn't understand from where it has to get the attribute.

The piece of code in loginhandler.jsp is tring resul=loginRes+" ";

session.setAttribute("errorcode",resul);
------------------------------------------------------------------------------------------------------
The piece of code in changepassword.jsp is :

String ercode=(String)session.getAttribute("errorcode");

String errcode=ercode.trim();

int erCode = Integer.valueOf(errcode).intValue();



if(erCode==3016){

...........
}


Can someone help me as to how i can manage to keep the code in changepassword.jsp and handle both the kinds of users.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2006
Posts: 1,454
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 129
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Ambiguity in using the same jsp

  #2  
Jun 19th, 2008
Uhm.... if (errcode != null) before the trim?
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Jun 2008
Posts: 16
Reputation: icorey has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 3
icorey icorey is offline Offline
Newbie Poster

Re: Ambiguity in using the same jsp

  #3  
Jun 19th, 2008
shouldn't the session persist even if you're redirecting to a new page? if not, would request.set/getParameter() work?
Reply With Quote  
Join Date: Feb 2006
Posts: 1,454
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 129
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Ambiguity in using the same jsp

  #4  
Jun 23rd, 2008
The thing is, from the way I read your post, the session will not contain any value under the key "errorcode". Therefore getAttribute("errorcode") will return null. Therefore ercode.trim() will result in a NullPointerException, therefore you need to add if (ercode != null).
Last edited by masijade : Jun 23rd, 2008 at 2:58 am.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JSP Forum

All times are GMT -4. The time now is 11:42 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC