This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes using of out.println in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "using of out.println in JSP" Watch "using of out.println in JSP" New topic
Author

using of out.println in JSP

Mike Vat
Greenhorn

Joined: Sep 09, 2008
Posts: 10
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 "
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gary Dhaliwal
Greenhorn

Joined: Oct 17, 2008
Posts: 11
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 %>">
asdf lkjh
Greenhorn

Joined: Oct 17, 2008
Posts: 12
@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
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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+"'/>");

%>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: using of out.println in JSP
 
Similar Threads
jsp:usebean
session tracking
Get values from the jsp
How to enable checkbox when checked in other checkbox dynamically
using the hidden value fields