Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:14:39+00:00 2026-05-31T21:14:39+00:00

I need to display to the screen some values which are read in method

  • 0

I need to display to the screen some values which are read in method defined in the script-let. The code below does not compiles:

<%!
    void displayRecursively(KnowledgeElement ke, ExtendsRelationshipService ers){
        List<ExtendsRelationship> erList = null;
        %><%=ke.getName()%><br /><%!
        try {
            erList = ers.findIncomingExtendsKERelationships(ke);
        } catch (Exception e) {}
        if (erList!=null){
            for (ExtendsRelationship er : erList){
                KnowledgeElement startKe = er.getStartKE();
                displayRecursively(startKe,ers);
            }
        }
    } 
%>  

<%
    KnowledgeElement ke = null;
    ke = (KnowledgeElement)request.getAttribute("knowledgeElement");
    ExtendsRelationshipService ers = (ExtendsRelationshipService)request.getAttribute("ers");
    displayRecursively(ke,ers);             
%>

The compilation error is:

PWC6199: Generated servlet error:
cannot find symbol
  symbol:   variable ke
  location: class org.apache.jsp.WEB_002dINF.ke_jsp

With .. %><%=ke.getName()%><% .. does not compiles as well.
Can someone please suggest how to resolve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:14:41+00:00Added an answer on May 31, 2026 at 9:14 pm

    Servlet containers compile JSP code into servlet classes following this approach:

    • When using the “<%! … %>” scriptlet symbols you are defining code that is going to be part of the servlet class itself, which allows you to define functions.
    • When using the “<% … %>” scriptlet symbols you are defining code that is going to be part of the “service” method of the servlet itself.

    So, what you are doing is mixing code that is being declared outside the “service” method with a reference to variable that is going to be copied inside the “service” method.

    To solve your problem I would add another parameter to your function and replace that “cross-reference” (or whatever it should be called). It would look like this:

    <%!
        void displayRecursively(JspWriter out, KnowledgeElement ke, ExtendsRelationshipService ers){
            List<ExtendsRelationship> erList = null;
            out.print(ke.getName());
            out.println("<br />");
            try {
                erList = ers.findIncomingExtendsKERelationships(ke);
            } catch (Exception e) {}
            if (erList!=null){
                for (ExtendsRelationship er : erList){
                    KnowledgeElement startKe = er.getStartKE();
                    displayRecursively(out, startKe,ers);
                }
            }
        } 
      %>
    

    When invoking that function in your other scriptlet you must past in the reference to the PrintWriter (which is an implicit variable for scriptlets that go inside the “service” method):

    displayRecursively(out, ke, era);
    

    Just notice that you will need page import of the “JspWriter” class in your JSP in order to compile.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a console application which screen scrapes some data, and now I need
I need to display some images which can be scrolled horizontally. Only one image
I need to display the .NET Compact Framework version number on the screen. I
I need to display a string which has a white space on a asp.net
I need to display some images. And I want to slide out one image
The code below plots some simple x-y data, but it has two problems that
I need to display some stats, numbers, and graphs about various game objects on
Ok so, what I need to do is change some numbers on the screen
i am developing one application with map view i need display the weather depends
I need to display an error message on rejecting a drop in my application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.