Solved

Two JSP Tags in 1 HTML page

Posted on 2006-11-02
6
219 Views
Last Modified: 2010-04-01
Hello!

I have a JSP page and I open <% jsp tag in it. Then I close it with %>

In first tag I define a variable: int a = 23;

Then I put a lot of HTML code... Now I want to print 'a' variable in middle of html. So I re-open <% JSP tag.

But it says 'a' is not defined!

What should I do?
0
Comment
Question by:CSecurity
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 17857002
have u tried

<%= a %>
0
 
LVL 3

Accepted Solution

by:
KnightFire earned 500 total points
ID: 17857486
Scope in JSPs is the same as java, if you get really stuck then examine the generated servlet that is created from the JSP.

objects comment is correct as <%= a %> should print the value of a. If it doens't then a must have gone out of scope, meaning you probably defined it within a loop or similar in the first set of JSP tags. Make sure that a is defined outside any loops or other constructs within the tags.
0
 
LVL 17

Author Comment

by:CSecurity
ID: 17857801
Again I got error in this line:

 out.print( titles[0] );

But I defined them at TOP of opening of <% JSP tag
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 3

Expert Comment

by:KnightFire
ID: 17857918
can you paste your JSP page?
0
 
LVL 10

Expert Comment

by:jaggernat
ID: 17858336
Make sure for every opening <% , there is a closing %>
Make sure all html tags are closed properly.

<html tags>

<%

All your java code

%>

<html tags>

<%

All your java code

%>
..
0
 
LVL 17

Author Comment

by:CSecurity
ID: 17860265
The problem was that I should define them at TOP of code... it was in try and catch! ALTOUGHT everytime it goes to try and never goes to catch (no error occurs) but it should define before everything!

Thanks all
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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
EJB MDB example 4 87
main method of string class 3 117
eclipse buid path vs tomcat lib path 10 34
null output 3 35
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 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