File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to pass string value from jsp to java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to pass string value from jsp to java class" Watch "How to pass string value from jsp to java class" New topic
Author

How to pass string value from jsp to java class

Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
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

Joined: Jan 08, 2009
Posts: 1397
    
    6

What is the error? Can you show us the class and method definition?


Swastik
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
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

Joined: Jan 08, 2009
Posts: 1397
    
    6

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

Joined: Dec 21, 2006
Posts: 197
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

Joined: Jan 08, 2009
Posts: 1397
    
    6

Sorry about my wrong understanding. Does this help?
Reshma Reddy
Ranch Hand

Joined: Dec 21, 2006
Posts: 197
Swastik,

Now I am getting user details into my java class. Thanks learned new thing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to pass string value from jsp to java class
 
Similar Threads
Html Radio buttons and Arraylist
Spring MVC-iBATIS problem with updating data from the form
Struts 2 checkboxlist error - list key could not be resolved
help with html radio tag
Arraylist in JSP with Html radio