aspose file tools*
The moose likes JSP and the fly likes Unmatched brace or incomplete EL expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Unmatched brace or incomplete EL expression " Watch "Unmatched brace or incomplete EL expression " New topic
Author

Unmatched brace or incomplete EL expression

vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Hi,

I am using JSTL in my JSP page:



I am unable to compile this line of code.

The message I see is "Unmatched brace or incomplete EL expression starting at column 0 at line 0".

Can some one help me regarding this?

Thanks,

-Vikas
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Passes JSP validation for me.

Probably something else above this line.

WP
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Actually, if I pass on a string "test" in the value it compiles.

I see the problem occuring only if I use the JSTL function.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Are you sure thats the line causing the problem?

And why are you stripping apostrophe's from the last name? :shock: If my last name was O'Brien, I'd be pretty ticked off.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

you mean like:


Paste yours.

WP
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Exactly.

O'Brian in our application is causing a javascript issue. it is breaking because of the '.

To get rid of that issue we are using this approach, for now, as it does not do a lot of harm for this.
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
William. Yes you were correct. That was the same code that is not having compilation problems !!
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Better not touch O'Sullivan !!!

;)

As I said, I copied your line exactly into a sandbox JSP and it validates fine.

So you are saying this occurs at run-time? When the application is running?

WP
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

vikas Gourishetty wrote:
O'Brian in our application is causing a javascript issue. it is breaking because of the '.

So you're stripping it out instead of properly escaping it? Really?
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Bear,

Yeah, I need to think on to find a better solution. But this one is causing few problems, so got to live with this right now. :(


William,

Its just the IDE (Jdeveloper) which is complaining. When I change this in the server's deployment folder (Very bad way). It has solved temporarily.


Thanks,

-Vikas
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 859

Does the IDE complain about:


WP
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
William,

I tried your code lol ...



Observed that this problem is occurring with the apostrophe '.

If I remove that It could compile. But It does not solve the purpose.

I thank your effort and time William.

-Vikas


Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Maybe your best approach would be to write a tag library whose purpose is to escape a string for Javascript. Then you wouldn't have to be hard-coding quotes in your EL expression.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16066
    
  21

Single and double quotes are 2 of the infamous 5 XML magic characters and therefore can be trouble.

Usually the type of syntax that's in your example works because XML can figure out what you mean from the context, but in cases where it doesn't work, you have to fall back on the entities. The entity for single-quote is "'". Note that final semicolon (;), because it's important.

In any event, trying to do even moderately complex logic in EL is a bugger both to code and debug. Plus, it's a violation of the MVC paradigm that says that the View should display and not attempt to calculate.

So I second Paul's recommendation. Instead of battling EL, you are better off moving the function into a JavaBean.


Customer surveys are for companies who didn't pay proper attention to begin with.
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Thank you Tim.

I will go with your suggestion. I will handle the ( ' ) at the bean level.


@William:

With this line of code my IDE does not complain:



used

& apos; instead of " \' "



Thank you all.

-Vikas
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unmatched brace or incomplete EL expression