This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to get value selected in dropdown without using javascript and before form submission  RSS feed

 
C Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, does anyone know how what is the equivalent of document.form[someform].name in scriptlet or jstl? What I want is to get the value of whatever the user selected in the dropdown box without using javascript. I know that in javascript I could just do something like this document.form['formname'].category and be able to display the value of the selected category.

<html:select property="category">
<html:options property="first" collection="categories" labelName="first" labelProperty="second" />
</html:select>

And also, I have to be able to refer to the category selected before form submission.

Thanks in advance for any help.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since all JSP code runs on the server (including scriptlets and JSTL) before the HTML page gets sent to the browser, how could the value that the user selects be fetched before the page even gets sent to the user?

Perhaps this article might explain why what you ask is impossible.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Submit form to server and use HttpServletRequest#getParameter().
 
C Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first, thank you both for your replies.

no i cannot submit it yet as I have to let it pass thru response.encodeURL before submitting. so I guess I have to change strategy because it's impossible to do what I want.

do you have any suggestion as to how I can accomplish this.

I need to pass the constructed url to response.encodeURL because I'm using UrlRewriteFilter and for it to be able to translate the outbound url, you have to use either response.encodeURL or c:url so it can translate it to the clean url. The thing is, based on the selected dropdown list by the user, I have to append that to the url via javascript to form the final url. But I cannot use response.encodeURL with parameter from a javascript as it's just impossible to do it. So I'm not sure anymore of other implementation where I could achieve what I want.
 
C Das
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anyone got any idea how can i accomplish my question above? i have not gotten any solution yet.. please help
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!