?
Solved

Problem in JSP script (print cannot be resolved)

Posted on 2009-04-06
12
Medium Priority
?
472 Views
Last Modified: 2012-05-06
Can you check attach code and attach file run result and where the problem and how can solve it ?
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%
	String vr_RegionId = "20";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body>
<script language="JavaScript">
  if (<%= vr_RegionId %>  == "1")
  {
	  <%
	  print.out(vr_RegionId);
	  %>
   }
</script>
</body>
</html>

Open in new window

Result-TestJSP.txt
0
Comment
Question by:bworld
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24076358
use

out.print(vr_RegionId);

instead.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24076373
by the way, you can always use javascript's document.write to write the output to HTML...

like:

>>

<script language="javascript">

document.write(<%=vr_RegionId%>);

</script>
0
 

Author Comment

by:bworld
ID: 24078405
Hello ryancys

I change the code and I use your example but I also modify if statement as follow: -
  if (<%= vr_RegionId %>  == "20")
because I want to see the result but when I run this code after modification there no result only empty page.

Check and test attach code please and where the wrong in code to display the result.

I use Tomcat 5.5 as a web application
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%
	String vr_RegionId = "20";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body>
<script language="JavaScript">
  if (<%= vr_RegionId %>  == "20")
  {
  	document.wrirte(<%= vr_RegionId%>);
	  //<%
	  //print.out(vr_RegionId);
	  //%>
   }
</script>
</body>
</html>

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24078455
a typo there...

document.wrirte(<%= vr_RegionId%>);

should be as:

document.write(<%= vr_RegionId%>);
0
 

Author Comment

by:bworld
ID: 24078557
I change it but still no result also please run script on your machine
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24078580
>>I change it but still no result also please run script on your machine

try clear your browser cache and try again, alternatively delete the compiled servlets on the "work" folder on your tomcat directory, because it works at my end.

cheers
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24078587
anyway, always use:

if ("<%= vr_RegionId %>"  == "20")

instead of:

if (<%= vr_RegionId %>  == "20")


for better handling
0
 

Author Comment

by:bworld
ID: 24078649
I do every thing but still display for me blank page
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24078697
Are you using IE?

try this to debug error in IE:

1. go to Menu Tools > Internet Options > Advanced Tab, make sure the "Show friendly HTTP error messages" is unchecked.


And I suggest you made all necessary changes, restart your Tomcat, and try again.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 24078712
finally, if using IE, close it and try start a new IE to test...
0
 

Author Comment

by:bworld
ID: 24078802
I do every thing
please run this code in your machine
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 24078870
I always tested my solution before I posted it.


I suggest you may rename your page and try again (to ensure it's not from browser cache)

from example below, i wil get "20" returned on the page:

test2.jsp:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%
        String vr_RegionId = "20";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body>
<script language="JavaScript">
  if (<%= vr_RegionId %>  == "20")
  {
        document.write(<%= vr_RegionId%>);
          //<%
          //print.out(vr_RegionId);
          //%>
   }
</script>
</body>
</html>

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question