Solved

Problem in JSP script (print cannot be resolved)

Posted on 2009-04-06
12
470 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 52

Expert Comment

by:Ryan Chong
ID: 24076358
use

out.print(vr_RegionId);

instead.
0
 
LVL 52

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 52

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 52

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 52

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 52

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 52

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 52

Accepted Solution

by:
Ryan Chong earned 500 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java cyclic graphs 15 223
print map entry 34 79
What kind of framework must i use to do that ? 2 45
jsp CRUD operations with and without prepared statement also hibernatge 1 46
The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
The goal of this blog is: - To define the incident management process - To go over the key elements of an incident management system - To look into incident alert management tools that integrate with ConnectWise.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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