Solved

Problem in JSP script (print cannot be resolved)

Posted on 2009-04-06
12
469 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 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
Technology Partners: 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 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

Industry Leaders: 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

Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

740 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