How would I set a java variable equal to the value in a javascript text field on a jsp?

I have tried


<% String name = application.getAttribute("txtName").ToString %>

but it didn't work. Thanks.