Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass string value from jsp to java class

 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my user page I am displaying all my user details (getting List of details from database), end of each row we have edit button to edit user details. We have to disable Edit button for current logged-in user, for this I have to check current logged-in user name with in users list, if equals disable edit button.
We have AuthenticationUtil class (this class contains logged-in user details). I am trying to send user name from jsp to java class to check user name is same or not the username in AuthenticationUtil class.
checking userlist

displaying user name


to check logged-in user details

here I am gettign error

Can anyone give me any clue, how to send user name to java class.
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error? Can you show us the class and method definition?
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik,
Can you check this line

I think this is not a correct way to pass values to java method.
In java class just checking username is equal or not with logged-in user and return boolean flag.

and error in jsp
and in runtime getting this error, if I reslove error in my jsp i won't get runtime error

 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before looking into the compilation error and everything allow me to have my view on this. As per my understanding you are using a loop to display the user details, and for each row you are hitting the database to validate. Now consider the following two scenarios

1. You have 1000 records, and the logged in user detail is at record number 1000. So the loop iterates for 1000 times, hits the db 1000 times.
2. You have 1000 records, and logged in user detail is at record 4, but you still have to iterate till the last record, hits the db 1000 times.

Do you think that you actually need to hit the db those many number of times. Why not rethink a bit? When the user logs in save that in session level variable, and compare with the session level variable. By this you will be able to eliminate number of db hits.

Correct me if my understanding is wrong.
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik,

In one DB call I am getting all user details (very limited users), for validation I am not hitting database just calling java method to check user.
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about my wrong understanding. Does this help?
 
Reshma Reddy
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik,

Now I am getting user details into my java class. Thanks learned new thing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic