• Post Reply Bookmark Topic Watch Topic
  • New Topic

Possible to nest quotation marks?  RSS feed

kat luna
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all. I've just been given 150 jsp pages designed for IE and asked to make them Netscape compatible. sigh.
Okay, so my question is... On almost every page they have textboxes coded like
<input type="text" name="new_effective_year" value="<%=request.getAttribute( "effective_year" )%>">
It was my understanding that quotation marks couldn't/shouldn't be nested like this, but should be
<input type="text" name="new_effective_year" size="4" maxlength="4" value="<%=request.getAttribute( 'effective_year' )%>">
However this app runs just fine (in IE and apparently Netscape, although QA has only tested with v4.5. I am wondering if these nested quotation marks will cause any problems in any browsers. I've only got authorization to change the HTML, and since the app works, I don't want to push for a change in coding style unless it really will cause problems.
Anyone with past experience in this issue?
Bear Bibeault
Author and ninkuma
Posts: 66207
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer to your question is no. In the following fragment:
value="<%=request.getAttribute( "effective_year" )%>">
the inner quotes never make it to the browser.
The way JSP works is that everything between the <%= %> delimters is evaluated as an expression on the server and then the result is substituted in the output stream sent to the client.
One of the best ways to understand how JSP pages work (and what happens when) is to look at the java code that is produced when the JSP page is translated. You would then see that the inner quotes are part of the java, and the outer quotes are part of the text strings that are sent to the browser as is.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!