Solved

Problem in JSP script (print cannot be resolved)

Posted on 2009-04-06
12
468 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
  • 8
  • 4
12 Comments
 
LVL 51

Expert Comment

by:Ryan Chong
ID: 24076358
use

out.print(vr_RegionId);

instead.
0
 
LVL 51

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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 51

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 51

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 51

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 51

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 51

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 51

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hashcode is calculated on the basis of value object 2 118
Best practices to work on a spring MVC project 1 126
own marker interface 1 57
collection output issue 9 37
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
This article describes how to reset your Windows 10 password when you've forgotten it.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

831 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