• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using of out.println in JSP

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I want to writeHTML tags in jsp code. I have written the below statement in JSP Server tags <% %>

<%

out.println("<input type="hidden" name="emp" value="<%=name.RETRIEVE_STATE%>">");

%>

I am getting the compilation errors. Can you pl help me how to write this ? I think the double Quotes inside<input? tag is causing the Issue. but how to solve this Issue ?

Error:

')' expected

("<input type="hidden" name="emp "
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you be wanting to do that? The whole purpose of a JSP is to allow you to specify the markup in template text. Building up the markup inside Java inside the JSP (a poor practice in and of itself) is simply silly.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of JSP simply as HTML with Java placeholders. There is no need to embed HTML code in Java.

Do it this way:
<input type="hidden" name="emp" value="<%= name.RETRIEVE_STATE %>">
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Mike: Don't get confused between jsp and servlets.

JSP's should be HTML with small Java.
Servlets should be Java with little or no HTML
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you just want to know ,

you have to use like below .. but it is highly discouraged as bear said above

<%

out.println("<input type='hidden' name='emp' value='"+java_value+"'/>");

%>
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic