This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uncaught SyntaxError: Unexpected token .

 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because that line is nowhere close to valid JavaScript syntax. What is it that you are trying to create there?
 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's frequently (but not always -- as per usual, it depends) a better option.
 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why we be here!
 
stephen r davidson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
er, on...
lightbulb went on...

:-
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic