aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes %@ include and Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "%@ include and Javascript" Watch "%@ include and Javascript" New topic
Author

%@ include and Javascript

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

This is going to sound like a Javascript question but I honestly believe this has something to do with the <%@ include rather than pure javascript, so bare (no pun intended) with me.

I'm trying something a bit different and just doing some general testing on an idea. But basically I am going to have a login form on every page that doesn't specifically require a login, but will unlock more features once the user logs in. I place all my JSP's under the WEB-INF folder. I have the following code:



My login jsp is simple:



Now what is happening is when I click the Login button, Firebug complains that login() is not a function. I have login defined in an included JS file. However, if I type login() at the Firebug console, the function is fond and fired.

Does this have to do with the way I am including the JSP (at compile time)? Is there something I can change to make this work? Thanks.

[ March 27, 2007: Message edited by: Gregg Bolinger ]
[ March 27, 2007: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Originally posted by Gregg Bolinger:
Does this have to do with the way I am including the JSP (at compile time)?


No, that cannot be the problem. The response is assembled on the server and sent to the browser as a "normal" HTML document. The included-ness of the fragment is not relevant.
[ March 27, 2007: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I don't think either that the problem is related to the way JSP is included.
Once the html has been generated, try to check ("view source") that you don't have any html inconsistencies.


[My Blog]
All roads lead to JavaRanch
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, everything looks fine. I'll keep playing around with it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Sounds odd. Have you tried it in other browsers just as a reference?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

I changed the function name from login() to doLogin(). After that is started working. I changed it back to login() and it stopped working again. No clue. Just tried in FF as I am on Linux.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I was trying the same !!
I tried changing the button name to "btnLogin" and it worked...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Looking at the DOM, the button called "login" is an Object with a constructor named login(). That must be the problem.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Satou kurinosuke:
Looking at the DOM, the button called "login" is an Object with a constructor named login(). That must be the problem.


Good call. I am moving this to the Javascript forum for others to laugh at me.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: %@ include and Javascript