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

EL Syntax error

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Hello I am trying to write a simple EL example. I am getting "EL Syntax Error" on my jsp page. No able to resolve it. Here is the code:

caseContacts.jsp


Output:
Case Contact List Information

Tue Aug 09 16:26:26 CDT 2011
The key is:${cont:caseContact_pk()}


CaseContactDto.java


caseContact.tld


CaseContactListImpl.java





Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Well, I have to say I haven't used taglibs exactly this way. But if your TLD says the function signature is "int getCaseContact_pk()" then shouldn't you call it as "${cont:getCaseContact_pk()}"? Or is there some rule that says you should apply the JavaBeans standards and drop the "get"?
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120

May be you are right, I got the example on Head First Servlets and Jsp, page 389, where it specifies function name in the Tld file different from the one method name defined in the class. It is not like a java bean. I changed my code to look like this:



Tld file:caseContact.tld



I removed the CaseContactDto.java as I realized it is not like java bean. When I try to output it still comes the same:

Case Contact List Information

Tue Aug 09 16:26:26 CDT 2011
The key is:${cont:caseContact_pk()}

Please help. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Is any EL being evaluates on your JSPs?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

P.S. Your tld URI should be a URI.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
You are right, No EL is being evaluated. Here is my web.xml if any suggestions.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Your web.xml is declared using the Servlets 2.3 DTD. This disables the EL.

Use the Servlets Schema declaration as appropriate to the actual version of Servlets you are using.

See the JspFaq for more info.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Thanks for the reply. Can you please forward me a link of how to migrate from Servlet 2.3 to Servlet 2.4, if I change the Web-app to the Servlet 2.4 on the Web.xml, I am getting lots of exceptions. I am using RAD 7.5.5.2. Please help.


Thanks,
Luke.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

What version of Servlets and JSP is support by your server? You'll only be able to use the level that it supports.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

If you're using RAD then you right click on the Web project and look for the "Migrate" option. If I recall right it isn't right there on the drop-down menu, you have to choose one of the obscurely-named options and "Migrate" is at the second level.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Bear, I am using IBM Websphere Application Server 6.1, it support Servlets 2.4 and Jsp 2.0

Paul - I right clicked on the project - J2EE - Specifications Migration Wizard. I tried to migrate but still getting the errors.

Here is my
org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="was.base.v61"/>
<fixed facet="jst.java"/>
<fixed facet="jst.web"/>
<installed facet="com.ibm.websphere.coexistence.web" version="6.1"/>
<installed facet="jst.java" version="5.0"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="com.ibm.websphere.extended.web" version="6.1"/>
</faceted-project>

and

org.eclipse.jst.common.project.facet.core.prefs.
classpath.helper/org.eclipse.jst.server.core.container\:\:com.ibm.ws.ast.st.runtime.runtimeTarget.v61\:\:was.base.v61/owners=jst.web\:2.4
classpath.helper/org.eclipse.jdt.launching.JRE_CONTAINER\:\rg.eclipse.jdt.internal.debug.ui.launcher.StandardVMType\:\:WebSphere\ v6.1\ JRE/owners=jst.java\:5.0
eclipse.preferences.version=1

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Luke Zechariah wrote:Bear, I am using IBM Websphere Application Server 6.1, it support Servlets 2.4 and Jsp 2.0

Then there is no reason that you should not be able to declare the app as a servlets 2.4 app.

I've moved this to the Websphere forum for the Websphere-savvy to have a look.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I'm more of a Websphere bumbler, but I did just migrate a project from 2.3 to 2.4 in Websphere so I will see if there's anything useful I might say by accident. Here's the start of my web.xml file:



Here's the start of one of my JSPs:



As for the files you posted, I've seen them occasionally when I synchronize the project with the repository but I don't know where to find them in the project, so I can't post my versions.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
I have ugraded my application from 2.3 to 2.5 successfully. Now it is identifying EL's and there is a new problem for the code on the jsp:



I am getting exceptions:


Error Message:JSPG0227E: Exception caught while translating /caseControl/caseContacts.jsp: /caseControl/caseContacts.jsp(0,1) --> JSPG0122E: Unable to parse EL function ${cont:caseContact_pk()}.

Root Cause:com.ibm.ws.jsp.translator.JspTranslationException: JSPG0227E: Exception caught while translating /caseControl/caseContacts.jsp: /caseControl/caseContacts.jsp(0,1) --> JSPG0122E: Unable to parse EL function ${cont:caseContact_pk()}. at com.ibm.ws.jsp.translator.visitor.validator.ELValidator.validateElFunction(ELValidator.java:497) at com.ibm.ws.jsp.translator.visitor.validator.ELValidator.validateELExpression(ELValidator.java:119) at com.ibm.ws.jsp.translator.visitor.validator.ValidateVisitor.visitJspELTextStart(ValidateVisitor.java:1237) at com.ibm.ws.jsp.translator.visitor.validator.ValidateVisitor.visitCDataTag(ValidateVisitor.java:873) at com.ibm.ws.jsp.translator.visitor.JspVisitor.processJspElement(JspVisitor.java:405) at com.ibm.ws.jsp.translator.visitor.JspVisitor.processChildren(JspVisitor.java:419) at com.ibm.ws.jsp.translator.visitor.JspVisitor.processJspElement(JspVisitor.java:234) at com.ibm.ws.jsp.translator.visitor.JspVisitor.visit(JspVisitor.java:216) at com.ibm.ws.jsp.translator.JspTranslator.processVisitors(JspTranslator.java:127) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJsp(JspTranslatorUtil.java:239) at com.ibm.ws.jsp.translator.utils.JspTranslatorUtil.translateJspAndCompile(JspTranslatorUtil.java:109) at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:465) at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:433) at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:292) at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:142) at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:325) at ne.dds.caseControl.efi.actions.CaseContactAction.doGet(CaseContactAction.java:42) at javax.servlet.http.HttpServlet.service(HttpServlet.java:718) at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1449) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443) at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175) at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859) at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165) at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202) at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766) at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896) at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)

Please help, thanks,
Luke.

Bibeault can you please move this to the JSP section as it is related to JSPs and not Websphere.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

Compare your call to the function with its declared signature. Do they match?
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Here is code I have:

caseContact.tld:


caseContacts.jsp


CaseContactListImpl.java
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Your function is expecting an HttpServletRequest parameter, but I don't see that you're passing it one. Can you explain how that works?
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120

Paul,

Thanks for the reply. Do you mean in my jsp I should write:



If my understanding is wrong, can you please help me understand what you meant?

Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

I don't know what you should do. I haven't ever written a function as a taglib. I'm just saying, that configuration doesn't look right to me.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

What do you think? If you declared a Java method to accept a parameter and didn't pass one, would it work? Of course not. How can your EL function execute if it expects a parameter and you don't pass one?
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Bear and Paul,

Thanks for the reply and yes got the answer and is working now. I changed the code on the jsp as follows:




On the web.xml:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

You don't need the tld declaration in the deployment descriptor. In fact, its considered a poor practice to put it there.

Rather, make sure that the TLD has a bona fide URI defined, and use that URI to let the container auto-discover the tld.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

P.S.
<uri>CaseContactsList</uri>

CaseContactsList is not a great choice for a URI. Something along the lines of:

http://org.luke-zechariah/contacts-tags

would be a better choice.
Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Bear you are right in but it is not working:

See I tried as you say, in my tld the uri is as follows in bold:



In the jsp I used:


But I am getting exceptions:

Luke Zechariah
Ranch Hand

Joined: Sep 27, 2005
Posts: 120
Ok Bear I got what you are saying. I changed the taglib-uri in the web.xml to something like this:



and the in the jsp to:


Thanks everyone for all the help. It is finally fixed.
 
Don't get me started about those stupid light bulbs.
 
subject: EL Syntax error