aspose file tools
The moose likes JSP and the fly likes %@ include and Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "%@ include and Javascript" Watch "%@ include and Javascript" New topic
Author

%@ include and Javascript

Gregg Bolinger
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

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 ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56192
    
  13

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 ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

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
Ranch Hand

Joined: Jul 11, 2001
Posts: 15230

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

Joined: Jan 10, 2002
Posts: 56192
    
  13

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

Joined: Jul 11, 2001
Posts: 15230

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: 14672
    
  11

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

Joined: Nov 24, 2005
Posts: 14672
    
  11

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

Joined: Jul 11, 2001
Posts: 15230

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: %@ include and Javascript
 
Similar Threads
Loading a file content in dropdown list
help with Prototype
%@ include and Javascript
Issue with displaying data back on the page
Regarding xml Data