This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSP and the fly likes uncaught SyntaxError: Unexpected token . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "uncaught SyntaxError: Unexpected token ." Watch "uncaught SyntaxError: Unexpected token ." New topic
Author

uncaught SyntaxError: Unexpected token .

stephen r davidson
Ranch Hand

Joined: Jun 23, 2013
Posts: 58
I specify the following line of code in a script in my jsp:



and when I debug the code in chrome, I see this:

var subscription = [{filter_case.account.name=null, event_salesforce_object_type=case, filter_case.product_family__c=null, event_type=simpledatecompare, filter_case.account.region__c=asdf, pmfkey=davst12, filter_case.owner.type=null, recipient_xmatters_group=dd, filter_case.component__c=null, filter_case.owner.name=null, last_updated_date=2013-08-11 00:00:00.0, id=9, last_updated_by=davst12, filter_case.priority=null, filter_case.account.billingcountry=null, recipient_email=ff, event_name=newcase}];

But my jsp page fails to build and I see this error the debugger:

Uncaught SyntaxError: Unexpected token .

If I remove the line from my javascript, then no syntax error.

Any idea why?


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

Because that line is nowhere close to valid JavaScript syntax. What is it that you are trying to create there?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
stephen r davidson
Ranch Hand

Joined: Jun 23, 2013
Posts: 58
Pulled it out of an example. :-(

I am trying to access a session attribute that I set in my java servlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

More info needed: what is the nature of the data of the session attribute, and how are you wanting to use it on the page?

If it's Java data that you want to make available to the JavaScript, you need to make sure that the JSP syntax creates valid JavaScript constructs. Remember, the JSP is merely "writing" the HTML page on the server to send to the client. There's no real communication between the Java and the client JavaScript.
stephen r davidson
Ranch Hand

Joined: Jun 23, 2013
Posts: 58
I found that I could do what I wanted in the controller, instead of trying to do it in the client.

:-)

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

That's frequently (but not always -- as per usual, it depends) a better option.
stephen r davidson
Ranch Hand

Joined: Jun 23, 2013
Posts: 58
I have slowed down, snails pace, turtle -- and am getting a surprising amount done by just trying to get one little piece at a time done so that I understand what I have done after I do it. As is the case often times, I was responding to your last post when the light bulb went off. :-) Thanks for all your help!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61451
    
  67

That's why we be here!
stephen r davidson
Ranch Hand

Joined: Jun 23, 2013
Posts: 58
er, on...
lightbulb went on...

:-
 
wood burning stoves
 
subject: uncaught SyntaxError: Unexpected token .