We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

How to write label in jsp?

techques
techques asked
on
Medium Priority
4,999 Views
Last Modified: 2012-05-06
Hi

I need to display a string value get from a parameter in a jsp page.

http://www.test.com/index.jsp?message=Welcome

How to display 'Welcome' in the jsp page? is it some kind like asp's label?
<%
if(request.getParameter("message")!=null){
String message = request.getParameter("message");
System.out.println(message); //how can i print it on a jsp page?
}
%>

Open in new window

Comment
Watch Question

<%
if(request.getParameter("message")!=null){
String message = request.getParameter("message");
out.println(message); //how can i print it on a jsp page?
}
%>

will put it on jsp page.

Author

Commented:
yes, I put it in jsp page already, but still cannot display
the code above shd def show it on your web page..

if your jsp have nothing else but just this code...
it should display Welcome on the page...

Author

Commented:
Yes, there is something else in the jsp page.

But, when the url returns
http://localhost:8080/test/index.jsp?msg=Welcome

The page does not display 'Welcome'.
Welcome display in console windows in eclipse.
<form name="loginjsp" action="login" method="post">
Email: <input type="text" name="email"><br>
Password: <input type="password" name="password"><br>
<input type="submit" name="Button" value="Login">
<%
if(request.getParameter("msg")!=null){
String msg = request.getParameter("msg");
System.out.println(msg);
}
%>
</form>

Open in new window

you need to change

System.out.println(msg);

to
out.println(msg);

System.out is console

out is the printwriter back to jsp

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
oh, sorry for my fault. I am a very newbie to jsp.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.