- This topic has 10 replies, 4 voices, and was last updated 20 years, 5 months ago by goetterwind.
-
AuthorPosts
-
dickonMemberHello all.
My MyEclipse is telling me that there is a compile error on one of my jsp pages, but I think that the compiler might be incorrect.
The code looks like this:
<% String language = "en" %> <jsp:include page="<%= language %>/abc" />
I get a compiler error on the second line, with the error description reading,
exptected %>”
(Yes, that’s percent greater-than double-quotes.)
However, my understanding of the JSP specification, there is nothing wrong with my code.
Is this a MyEclipse bug? Have I written incorrect code?
Thanks
JDG
System information:
– Eclipse 2.1.2 (Build id: 200311030802)
– MyEclipse 2.7.1 (Version: 2.7.1, Build id: 200403241200-2.7.1-GA)
– this is a clean install of eclipse and MyEclipse.
– java 1.4.2_02
– OS: Windows XP
Riyad KallaMemberYou are missing a semi colon at the end of your 1st line, after the “en”. An expression, <%= blarg %>, does not need one because it is just that, an expression. However a scriplet, <% String blarg = “blarg”; %> does need one, because that scriplet can be expanded to man lines of Java, so the compiler needs to know where the lines of code end. Take the example:
<% String blarg = "ham"; int length = blarg.length(); %>
dickonMemberThanks Riyad, however, that doesn’t solve the problem.
Even after correcting the mistake, my original message stands. (It was a slightly contrived code block used primarily for demonstration purposes) In other words, the following code
<% String language = "en"; %> <jsp:include page="<%= language %>/abc" />
(note the new semi-colon) still produces the same error stated in my first post:
exptected %>"
Interesting, so MyEclipse possibly did two mistakes: it didn’t find an error with the first line when it should have, and then it found an error with the second line of code, possibly when it shouldn’t have.
What’s the situation: is my code incorrect wrt the JSP specs, or is MyEclipse incorrecting finding an error?
JDG
Riyad KallaMember1) Please create a new JSP file that has just enough lines to duplicate this problem
2) Post the entire contents here…That error, expected %> sometimes occurs when some unrelated line is missing a closing brace, I’d like to look at the whole file and reproduce it on my end before sending you off in every direction trying to troubleshoot this.
dickonMemberI used the New JSP wizard (File->New->JSP), and added the two lines below the HTML break tag…
<%@ page language="java" import="java.lang.*,java.util.*" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'MyJsp.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> This is my JSP page. <br> <% String lang = "en"; %> <jsp:include page="<%= lang %>/page" /> </body> </html>
JDG
Riyad KallaMemberPerfect test-case, thank you for making this. I’ll pass it along, although admitedly this has me scratching my head.
As a quick fix (or maybe the ‘right’ way to do this) move your appending page path inside of the expression:
<jsp:include page="<%= lang + \"/page\" %>" />
You need to escape the quotes. OR, just make it part of the “lang” variable.
No OperationMember<jsp:include page=”<%= language %>/abc” />
unfortunately all StandardActions AND CustomActions accept runtime attribute values only in the forms
attr="<%= ... %>"
or
attr='<%= ... %>'
regards
NOP
dickonMemberWhat are “StandardActions” and “CustomActions”? Are they internal constructs to MyEclipse, or are they definitions in the JSP specification?
JDG
No OperationMemberThe names are taken from the original JSP specification. Have a look into jsp-2_0-pfd3-spec.pdf.
standard actions start with
<jsp:...
custom actions start with the prefixes introduced by taglib directives
<%@taglib prefix="foo" uri="/bar"%> <foo:...
NOP
Riyad KallaMembernop,
Is this then not a bug? Can I close the thread?
goetterwindMemberi didn’t check back for the spec, but to my knowledge, nop is right
you have to put the whole thingie into rt<taglib:tag attribute='<%= “wont” %>work’ />
<taglib:tag attribute='<%= “will work” %>’ />with jsp EL it should also work like this
<taglib:tag attribute=’${“will”} ${“also “}work’ />
MAYBE you should change that confusing error message :))
regards
axel -
AuthorPosts