Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Access jar's resources within a servlet

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Access jar's resources within a servlet

    Hello all first thanks for all the useful content I found on this forum.

    I have a jar without classes, it contains only resources like images scripts etc. this jar is present in the dir WEB-INF/lib of my servlet.

    How can I access the resources packed in the jar?
    I searched but without success... Any help is appreciated.

    Thanks, Roger


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Access jar's resources within a servlet

    As a starter, have a look at http://download.oracle.com/docs/cd/E...r/JarFile.html

    You can use a JarFile object to open up a jar file and read its entries.

    // Json

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Access jar's resources within a servlet

    If the jar file is on the classpath, you could use one of the getResource() or getResourceAsStream() methods.

Similar Threads

  1. What are the requirements to develop Servlet Application?
    By yousef atya in forum Java Servlet
    Replies: 2
    Last Post: July 28th, 2011, 06:20 PM
  2. Convert a project into JSP-Servlet
    By ali_hadian in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: June 25th, 2010, 08:54 AM
  3. servlet and socket plz HELP
    By Mokhtar in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 8th, 2010, 09:21 AM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM
  5. ha-jndi client is servlet
    By supriya ramjee in forum Web Frameworks
    Replies: 0
    Last Post: July 31st, 2009, 02:02 AM