• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass string value from jsp to java class

 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swastik,

Now I am getting user details into my java class. Thanks learned new thing.
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic