Two Laptop Bag*
The moose likes JSP and the fly likes using  html:button  with scriptlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "using  html:button  with scriptlets" Watch "using  html:button  with scriptlets" New topic
Author

using html:button with scriptlets

Steve Levin
Greenhorn

Joined: Jul 23, 2004
Posts: 11
Hi,
I'm trying to open a new browser window when a user clicks on an html:button Like the following:



onclick purposely misspelled

The scriptlet contained in the tag is a dynamic url decided at runtime.
The problem I'm having is that the scriptlet within the javascript part of the tag isn't recognized as a scriptlet. Is there a different way to insert the dynamic url contained in the scriptlet into the javascript within the tag?

Any help is appreciated
Thanks
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30356
    
150

Steve,
It looks right the way you have it. From JSP's point of view, there isn't any difference between a scriptlet in a Javascript or Struts tag. You can verify this by placing <%=pdfFile%> elsewhere on the page to see what happens.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

You can't use a scriptlet as just part of the attribute of a custom action. It must be all of the attribute, or none.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Levin
Greenhorn

Joined: Jul 23, 2004
Posts: 11
If I can't use a scriptlet as just part of the attribute, then how can I pass in the url contained in the scriptlet to the javascript function. Is there another way?
Steve Levin
Greenhorn

Joined: Jul 23, 2004
Posts: 11
Nevermind, I figured it out, I just created a String containing the javascript function with the url and then passed in the whole String as the arg to onclic
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61084
    
  66

Bingo.

This is yet another of the many problems with continuing to use scriptlets in JSP pages.
[ October 22, 2006: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
 
subject: using html:button with scriptlets