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 3217632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:26:02+00:00 2026-05-17T15:26:02+00:00

From a servlet, I’m forwarding the request to a JSP page which renders a

  • 0

From a servlet, I’m forwarding the request to a JSP page which renders a FusionChart.
But I’ve a problem in loading the chart. The JSP file is not detecting the JavaScript file. The folder structure is:

axis
 |
 WebContent
      |
     WEB-INF
        |
       classes
         |_ com 
         |_FusionCharts.js
         |_MyChartJsp.jsp
         |_Line.swf

And the JSP code:

<html>
<head>
<script language="text/javascript" src="/WEB-INF/classes/FusionCharts.js"></script>
</head>
<body bgcolor="#ffffff">
<div id="chartdiv" align="left">The chart will appear within
this DIV. This text will be replaced by the chart.</div>
<script type="text/javascript">

var foo = //value fetched from DAO
var myChart = new FusionCharts("/WEB-INF/classes/Line.swf",
            "myChartId", "1000", "500");

    myChart
            .setDataXML("<graph caption='aCaption' xAxisName='xAxis' yAxisName='yAxis' showNames='1' decimalPrecision='0' formatNumberScale='0'>"+foo+"</graph>");
    myChart.render("chartdiv");
</script>

</body>
</html>

The Servlet code to forward the request:

final RequestDispatcher requestDispatcher = request.getRequestDispatcher("/WEB-INF/classes/MyChartJsp.jsp");
requestDispatcher.forward(request, response);

The request is getting forwarded to the JSP. But the chart is not getting displayed because it is unable to figure out what FusionCharts is in the line

var myChart = new FusionCharts("/WEB-INF/classes/Line.swf",
                "myChartId", "1000", "500");

I tried

src="/FusionCharts.js"

src="FusionCharts.js"

but no luck.

Has it something to do with the request being forwarded??

  • 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-17T15:26:02+00:00Added an answer on May 17, 2026 at 3:26 pm

    You cannot have .js (or .swf, .jpg, etc.) files in WEB-INF – they are not publically accessible.
    Move it to /js/

    There is no reason to hide static resources (like scripts and css) in WEB-INF. If you insist on that, you should make a servlet that, given the name of the js/css, would read it from its location and will serve it as a response. This is what the default servlet does when you access static resources.

    The flow of the page loading is as follows: the browser sends a request to the servlet; the servlet forwards internally to the JSP, and the JSP is rendered as a response; then the browser parses the <script> tag and fires another request to the script. If the script is not accessible via URL, it’s not loaded.

    Then, to make the script url fixed to the servlet context root, use

    src="<c:url value="/js/script.js" />"
    

    This will work regardless of what is the current url

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

Sidebar

Related Questions

I have a JSP page which display a list from servlet, it has a
Can I call a servlet from JSP file without using a HTML form? For
I want to dispaly a result parameter which return from servlet to jsp after
I wrote a sample html which retrieves the JSON from servlet and displays. But
I have a servlet S which handles callbacks from a 3rd party site. The
I am creating a table based on result from servlet, which contains a checkbox
I am working on the jsp/servlet/ajax application. I use XMLHttpRequest to pass values from
How can I pass variable from servlet to jsp? setAttribute and getAttribute didn't work
I have a JSP form which is made of <input type=file/> tag alone for
I'm trying to return an html, page using out.print(); from a servlet, and I

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.