Solved

Problem in JSP script (print cannot be resolved)

Posted on 2009-04-06
12
463 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 49

Expert Comment

by:Ryan Chong
ID: 24076358
use

out.print(vr_RegionId);

instead.
0
 
LVL 49

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
 
LVL 49

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 49

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 49

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 49

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 49

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 49

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now