•
•
•
•
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
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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.
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
----------------------------------------------
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
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
----------------------------------------------
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
![]() |
•
•
•
•
•
•
•
•
DaniWeb JSP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the JSP Forum
- Previous Thread: using java classes and generics in JSP
- Next Thread: How to pass the paramter from main JSP to the included JSP



Linear Mode