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

EL Syntax error

 
Luke Zechariah
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is any EL being evaluates on your JSPs?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Your tld URI should be a URI.
 
Luke Zechariah
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right, No EL is being evaluated. Here is my web.xml if any suggestions.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compare your call to the function with its declared signature. Do they match?
 
Luke Zechariah
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is code I have:

caseContact.tld:


caseContacts.jsp


CaseContactListImpl.java
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64828
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic