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

  • Home
  • SEARCH
  • 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 9048455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:09:39+00:00 2026-06-16T12:09:39+00:00

I´m doing a javaEE application and I´m using spring to inject my ejbs and

  • 0

I´m doing a javaEE application and I´m using spring to inject my ejbs and WAS7, currently I´m running it in a windows environment altough in the end it will run in a unix environment. So I create a java class that acts as my controller for spring and I´m supposed to get some data from a jsp and turn it into an excel. So when I try to get an image from my web-content folder so I can put it into my excel y get file not found.
This is what I´ve tried so far without success:

    String path = File.separatorChar + "img" + File.separatorChar +  File.separatorChar + "logoCorporativo.jpg";
    System.out.println(path);

    try {
        FileInputStream fis = new FileInputStream(path);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

and

        String path = File.separator + "img" + File.separator +  File.separator + "logoCorporativo.jpg";
        System.out.println(path);

    try {
        FileInputStream fis = new FileInputStream(path);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

I found that when I typped “http://localhost:9080/AdminMapasWeb/img/logoCorporativo.jpg” into my browser I can see the image.

Does anyone am I getting a FileNotFound Exception???
Thanks in advance.

  • 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-06-16T12:09:40+00:00Added an answer on June 16, 2026 at 12:09 pm

    Use

    File file = getRequest().getServletContext().getRealPath("/img/logoCorporativo.jpg");
    

    getRealPath convert a URL root relative path (using slashes “/”) to a File.
    If the war does not unpack itself on deployment, getRealPath returns null.

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

Sidebar

Related Questions

I'm doing a Web application using Spring 3.1.0.RELEASE, JSF 2.x, JPA 2 with Hibernate
i'm creating a very simple (hello World quality) web application using spring mvc 3.0.
I'm developing a Java enterprise application, currently doing Java EE security stuff to restrict
I'm doing my first Java EE web application using glassfish and netbeans. When I
I am building an application using Spring Framework 3.1 I am having my controllers
I'm writing my first Java EE application, using EJBs, Servlet, JSPs and the likes.
Environment Application server: JBoss AS7 (7.1.1 Final) JPA implementation: EclipseLink (2.4.1) OS: Windows 7
I'm currently doing web application development in PHP. Management has told us we're standardizing
We are currently running a Java integration application on a Linux box. First an
Doing an ajax get request works as expected using the following code: $.ajax({ type:

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.