This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes How to pass value in href tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to pass value in href tag" Watch "How to pass value in href tag" New topic
Author

How to pass value in href tag

malik ge
Ranch Hand

Joined: May 13, 2011
Posts: 69
Hi,
I have two text fields on my jsp page.
I want to know how can I pass the value of "username" text field to the servlet, when I click the "check if user name already exist" hyperlink

olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81

Hi,

You will have to use some script for that.
Clicking the href, the value of username should be retrieved trought script, and be passed along with the href-url.

What don't you just let the user post his data, and just give an error, telling that the username exists? You just show the same page again with the same data, but with an error on top. You could even go further and suggest a username...
Venkateswara Rao K L
Greenhorn

Joined: Aug 27, 2010
Posts: 13
Hi Malik,

You will have to write some script for that. You can attach an onClick event to the <a> tag and pass the value of the username to that funuction.
In the fucntion make call to the servlet that validates the availabilty of the usename. As olivier suggested you can you can even suggest the user the avilable user names.

Thanks,

Venky
mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 243

Why dont you go for AJAX it will solve your problem.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60773
    
  65

mallikarjun dontamsetti wrote:Why dont you go for AJAX it will solve your problem.

Ajax will in no way solve this problem.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: How to pass value in href tag
 
Similar Threads
What is the equivalent to scriptlets for invalidating the session in jsp
Jsp Login Page Problem
how to use the servlet to get the value from JSTL c:set?
"Type mismatch: cannot convert from Cookie to String"
Can a EL expression pass a value that was entered into a form?