Doubt in locating a file in context parameter

I have got a file named mylibrary.txt in WEB-INF/data directory.
I wish to map the file in context Parameter.
While trying this,
<context-param>
     <param-name>library-file</param-name>
     <param-value>/WEB-INF/data/my-library.txt</param-value>
</context-param>     
I got a null pointerException while reading the file in my servlet. I am using Eclipse.

The code as follows
public class ListLibraryServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    /* (non-Java-doc)
      * @see javax.servlet.http.HttpServlet#HttpServlet()
     public ListLibraryServlet() {
          super();
     /* (non-Java-doc)
      * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          response.setContentType("text/html");
          PrintWriter out=response.getWriter();
          ServletContext context=getServletContext();
          List dvd=(List)context.getAttribute("dvdlist");
          out.println("<head><title>ListLibraryServlet</title></head>");
          out.println("<body bgcolor='D2B48C'>");
          out.println("You currently have <b>3</b> DVDs in your collection<br>");
          out.println("<table>");
          out.println("<tr>");
          out.println("<th>Title</th>");
          out.println("<th>Year</th>");
          out.println("<th>Genre</th>");
          out.println("</tr>");
        Iterator it=dvd.iterator();
        while(it.hasNext())
          DVDItem item=(DVDItem)it.next();
          out.println("<tr>");
          out.println("<td>");
        out.println(item.getTitle());
        out.println("</td>");
          out.println("<td>"+item.getYear()+"</td>");
          out.println("<td>"+item.getGenre()+"</td>");
          out.println("</tr>");
          out.println("<tr>");
        out.println("</table>");
        out.println("</body>");
        out.println("</html>");
     /* (non-Java-doc)
      * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
     }                   I am retrieving the file as
public class InitializeLibrary extends javax.servlet.http.HttpServlet implements javax.servlet.ServletContextListener {
    /* (non-Java-doc)
      * @see javax.servlet.http.HttpServlet#HttpServlet()
     public InitializeLibrary() {
          super();
     public void contextInitialized(ServletContextEvent event)
     {   InputStream is=null;
         BufferedReader reader=null;
          List dvdlist=new ArrayList();
          ServletContext context=event.getServletContext();
          String libraryfile=context.getInitParameter("library-file");
          try
          is=context.getResourceAsStream("libraryfile");
          reader=new BufferedReader(new InputStreamReader(is));
          String record;
          while((record=reader.readLine())!=null)
             String[] fields=record.split("\\|");
             String title=fields[0];
             String year=fields[1];
             String genre=fields[2];
             DVDItem item=new DVDItem(title,year,genre);
             dvdlist.add(item);
          context.setAttribute("dvdlist",dvdlist);
          catch(IOException e)
               e.printStackTrace();
          catch(Exception e)
               e.printStackTrace();
     public void contextDestroyed(ServletContextEvent event)
}

Similar Messages

  • Taw web xml file ADMINREADCC8 context parameter

    when I run the scipt for CCA the Useme.sql I only see the ADMINCC8 user I don't see the ADMINREADCC8 so I'm not sure what to put on the following context for web.xml
    <!-- Needs to be removed for MSSQL-->
    <!--<context-param>-->
    <!--<param-name>databaseSchemaReadOnly</param-name>-->
    <!--<param-value>ADMINCCREAD813</param-value>-->
    <!--</context-param>-->

    This is the eclipse error
    The content of element type "web-app" must match "(icon?,display-
    name?,description?,distributable?,context-param*,filter*,filter-mapping*,listener*,servlet*,servlet-
    mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-
    ref*,resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-
    ref*)".
    Web.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
            PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
            "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
         <display-name>tapestryHiber Tapestry 5 Application</display-name>
         <context-param>
              <!-- The only significant configuration for Tapestry 5, this informs Tapestry
                   of where to look for pages, components and mixins. -->
              <param-name>tapestry.app-package</param-name>
              <param-value>com.kids.crm</param-value>
         </context-param>
         <filter>
              <filter-name>app</filter-name>
              <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
         </filter>
         <filter-mapping>
              <filter-name>app</filter-name>
              <url-pattern>/*</url-pattern>
         </filter-mapping>
         <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>/WEB-INF/spring/spring-servlet.xml</param-value>
         </context-param>
         <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
         </listener>
    </web-app>
          Edited by: csckid on Aug 29, 2011 5:51 AM

  • Location of file sites.log

    Dear Forum Users:
    Please, i need to know where is located log file sites.log. I know that this file is located in logs folder. But i don't know which is the complete path. I work with a server that contains an OWCS plattform.
    Thanks in advance and excuse for my english (This language is not my native language).

    Basically the path can be selected at installation time.  The parent folder you're looking for is the "Sites home folder".
    The sites.log file is located in the <wcshome>/logs folder.  The <wcshome> folder is the folder corresponding to the "inipath" context parameter in the web.xml file.  It's usually located in the home folder of the user who is running your instance of Sites. 

  • How do I locate RAW files to export from a managed library?

    I have a decade's worth of managed Aperture libraries. The majority of the Masters are jpeg files but at least 30% of the originals are raw files. I am wanting to change to a referenced library structure which is accessible from other applications. Can anyone tell me how I can tell, from within Aperture, which projects are raw based and how to retrieve these raw image files? I expect there is a simple answer which will prompt a "duh" and a forehead slap but it is eluding me at the moment. I know that if I open the library package and rummage around I can locate raw files but the context is lost and often utterly confusing in the arcane folder structure Aperture uses.

    You can create smart albums or searches in Aperture to find all images with RAW original files.
    Use the command:   File > New > Smart album
    Then add a rule from the "Add Rule" drop down menu to the Smart Settings HUD:
    "File Type is RAW"
    and click the checkmark next to the rule.
    This will show you all images that are RAW.
    Just to be sure, you know, that you need to be careful not to move or modify referenced images in any way by accessing them from other applications, right?

  • How to go to the location of file that I received ...

    How to go to the location of file that I received on skype? I was able to do it easily in old version. 
    Now, I recieved the zip file. If I click on the file, it shows the Zip File View. I don't know where that file is downloaded. (of cuz, need to dip where I set the download path.) In old version of Skype, there is a link where we can open the file in windows explorere.
    I would suggest that the Skype UX or development team needs to read "Don't make me think" short book. 
    Update: There are other people who reported the issues in 2013 http://community.skype.com/t5/Modern-Windows-from-​Windows/Where-are-the-files-saved-that-someone-sen​... Please don't copy all metro skype UI to skype desktop without thinking about usability and royal user expereince. Thanks! 
    Note: Another thing: THis forum seems like it let me post without me logging in. But when I submit the context, it redirects to login page. So, I chose to login with my account and it redirect back me to this forum and the post that I wrote a few min ago was totally gone.. Seriously? 
    Solved!
    Go to Solution.
    Attachments:
    Fuck New UI.png ‏9 KB

    What about this?
    Attachments:
    ShowInFolder.jpg ‏28 KB

  • Access Context Parameter in Java Bean.

    Hi,
    I want to access the Context parameter set by the web.xml from a java bean or simple java class. For example, If I have database connection details in my web.xml and I want to get these in a Java Bean of a class which will pick up the values and create a Connection object and return to the guy calling it, either JSP or servlet.
    I have a idea of using InitialContext class. But I doubt it works for
    Context parameter defined in the web.xml.
    It worked if I use like this for DataSource object which is created in my application server.
    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("OMSDataSource");
    return ds.DatabaseConnection.getConnection();
    So how can I access a parameter like this..
    <context-param>
    <param-name>Webmaster</param-name>
    <param-value>[email protected]</param-value>
    </context-param>
    Cheers.
    L G Goundalkar

    Greetings,
    Hi,
    I want to access the Context parameter set by the web.xml from a java bean or simple java class.The bean doesn't have direct access to the context object so that access must to supplied to it - i.e by calling getServletContext() and passing the resulting reference to the bean.
    For example, If I have database connection details in my web.xml and I want to get these in a Java
    Bean of a class which will pick up the values and create a Connection object and return to the guy
    calling it, either JSP or servlet.Why not write a DAO to handle the JSP or servlet's access needs? The DAO can be initialized at application start with a context listener and the initialized instance placed in the context where the JSP or servlet can get it directly. ;)
    I have a idea of using InitialContext class. But I doubt it works for Context parameter defined in the
    web.xml.Not for context parameters (a different "space" from the JNDI namespace ;). But, of course, it does work for "environment entries" which may also be placed in the web.xml DD (er, presuming your web container supports JNDI, of course).
    Cheers.
    L G GoundalkarRegards,
    Tony "Vee Schade" Cook

  • Reg..csv file as input parameter in sqlloader

    Hi,
    I have .ctl file. every time i received the file name in diff name.
    rather than hardcode file name i wants to take .csv file as input parameter plesase do help in this.
    here is the code..
    OPTIONS (SKIP = 1, BINDSIZE=100000)
    LOAD DATA
    CHARACTERSET WE8ISO8859P1
    INFILE '/WOAU1/bkp/pgp_masterkey.csv'
    BADFILE '/WOAU1/bkp/pgp_masterkey.bad'
    DISCARDFILE '/WOAU1/bkp/pgp_masterkey.dsc'
    Thanks
    Atul

    A better alternative would be to avoid using SQL*Loader and instead use External Tables for which you can use an ALTER TABLE statement to change the LOCATION of the table (which details the filename). (A valid reason for using EXECUTE IMMEDIATE in PL/SQL). That way you keep all your control inside the database and you're not messing about with o/s scripts to pass different parameters to an external program.

  • Everything on my desktop disappeared. i tried using the finder to locate specific files and they are missing. Help!

    i'm using a macbook pro retina, 2.4 GHz Intel Core i7, 8GB. operating OSX Yosemite 10.10.1
    everything on my desktop disappeared. i've managed to make my HD reappear on my desktop but my files etc are nowhere to be found. i tried using the finder to locate specific files and they are missing. Help! I foolishly filled up my desktop with piles of screen grabs and folders - no doubt that was the cause... what do i do, aside from punish myself for being so stupid?

    Could you have logged into another account?
    If you go to System Preferences>Users and Accounts what accounts are listed?
    To show users at login go to the Login Options of chanck the box that says show list of users.
    If they they are gone and you can't find them then restore them from a backup

  • Getting an error message trying to open a file, "Missing required parameter 'from' for method "open'. What do I do?

    Getting an error message trying to open a file, "Missing required parameter 'from' for method "open'. I've tried opening in CC and CS5. What do I do? Can the file be salvaged?

    Try opening as a copy, and/or copying the file to a new location and try opening that.

  • Context parameter

    Hi,
    Currently I am migrating my tomcat application to sun java web server 7.1.
    I am getting annoyed due to failed set context parameter, How to set servlet context paramerer outside web.xml. Currently I use separate xml file or add it in tomcat server.xml like
    <?xml version="1.0" encoding="utf-8"?>
    <Context>
         <!-- #Internal API -->
           <Parameter name="login_uri" value="http://127.0.0.1/cgi-bin/login.fcgi"  override="false"/>
    </Context>This parameter shared by all wars. How do I set this in sun one web server, if is there way to set it via admingui it will me much better.
    Thanks

    you might want to use 7.0 update 4 (http://www.sun.com/webserver) . there is no 7.1 yet .
    you should be able to do this within <https-<hostname>/config/default-web.xml (append it at the end just before the last line..)
    <context>
    </context>
    </web-app>
    finally, if every thing is working out for you, then you need to do the following command so that admin gui is aware of your manual changes
    bin/wadm pull-config user=admin config=<hostname.domainname> <hostname.domainname>

  • Access context parameter in web.xml

    Hi, all. I add a entry into Context Initialization parameter at tab Application in file web.xml with name: path and value img/product. I don't know how to get the context parameter. I want access the context by EL in file .jspx or .jsf, as #{path} but error. Can anyone help me.Thanks.

    Hi,
    have a go with
    #{initParam['param_name_here']}"
    alternatively
    #{facesContext.externalContext.initParameterMap['param_name_here']}
    Frank

  • Define a context parameter not using web.xml

    Dears,
    With a web.xml file, it is possible to define a context parameter available in the web app via de ServetContext.getInitParameters method.
    Is it possible to define a context parameter not using the web.xml file ? Can I, in a java Class, init a custom context parameter ? (for exampel, init as a context param a key/value pair read from a property file).
    PS: the need is that the value (hmac key) currently define in the web.xml needs to be updated monthly. Apparently, under WebSphere (the app server we are using) changing the web.xml of the deployed app it not enought for it to be taken into account.
    Sincerely,
    Beno�t Bertrand

    Is it possible to define a context parameter not
    using the web.xml file ? Can I, in a java Class, init
    a custom context parameter ? (for exampel, init as a
    context param a key/value pair read from a property
    file).Does it necessarily have to be a value retrieved through the context param ? AFAIK, there's no way you could programatically 'set' an init param, which going by the name, 'init param' is quite understandable.
    You could define this value in a property file and read it in, in the init method. You should provide a mechanism to reload the new value after 'x' days. One approach is a Timer that does the job, do have a look at SteveJLuke's recommendations on the same in this thread
    http://forum.java.sun.com/thread.jspa?threadID=637355&tstart=0cheers,
    ram.

  • Error: "We're having a problem opening this location on file explorer. Add this website to your trusted sites list and try again"

    Hello,
    When i try to open document library from SharePoint Production portal then it throws the specified error. However, when i open document library from SharePoint Development portal then it opens it in file explorer quite easily.
    Production portal is on https whereas development portal is on http. Also, UAG has been configured on production portal.
    Any idea where it's getting stuck up? Surely, this is not a browser issue on Windows 7 as it's opening the development portal's document library on the same machine.
    I've also done following things:
    - Configured Desktop Experience on production environment
    - Installed the hotfix for Windows 7
    Regards,
    Sohaib
    Sohaib Khan

    Hello Sohaib.
    Here is the list of causes defined here.Hope it helps you
    The cause and the resolution methods are the following:
    Cause: There is a missing Root site collection...
    Resolution: Check and ensure,  that the “Managed Paths” are not changed in the web Application’s page, there is a (root) explicit for
    this web application and there is a working Root site collection.
    If for any reason this is not the case in your environment, you may try the following:
    - Apply (if not already) the following Hotfix to one of those clients:
    Error when you open a SharePoint Document Library in Windows Explorer or map a network drive to the library after you install Internet Explorer 10 in Windows 7 or Windows Server 2008 R2 
    http://support.microsoft.com/kb/2846960
    Then, try to delete the cache of the IE browser before reproducing the issue. Check the result..
    - Try to temporarily disable the Antivirus and test again.
    - Check if you have installed the Desktop Experience feature on the SPS13 server.
    - Check if you face this behavior with all users, Or only with some specific ones, Or with all different client OSes.. 
    Otherwise you will need to collect the logs to further analyze...
    http://blogs.msdn.com/b/george_bethanis/archive/2013/11/04/sps13-quot-open-with-explorer-quot-random-error-quot-we-re-having-a-problem-opening-this-location-in-file-explorer-add-this-web-site-to-your-trusted-sites-list-and-try-again-quot.aspx
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Error message when trying to play music on computer states The song ... could not be used because the original file could not be found.  However, my library shows how many items and the GBs used.  How do I locate the files?

    When I try to play my iTunes music on my computer, an error message comes up and state "The song (title of song) could not be used because the original file could not be found.  Would you like to locate it?
    When I click on Locate It, I cannot find where the music file may be located.  Does anyone have any suggestions?
    This all occurred when I attempted to do a backup to an external hard drive.  Unbeknownest to me, the files did not copy over and do not appear on the external hard drive. 
    When I open my iTunes library, at the bottom of my music list it shows how many songs and the GBs, so it appears that the files are still there; however, cannot be located.
    Thank you.

    Hi angela dfromtx,
    When tracks in iTunes display a it means the file cannot be located; it may have been moved or deleted. You'll have to locate the file manually if it is still available. For more information refer to the following article:
    iTunes: Finding lost media and downloads
    http://support.apple.com/kb/TS1408
    Alternatively, if your media was downloaded from the iTunes Store, you may be able to download it again free of charge:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Thanks,
    Matt M.

  • How do I locate multiple files at one time?

    I've moved a few songs around in my computer's files, and each time I'd go back to locate the files, it asked me if I would like to locate the original files for other songs. Today I tried to do the exact same thing, but it doesn't give me the same option anymore. Now, if I want to locate any of the songs currently missing, I have to do it manually one by one. Is there any way I can get the option back?

    Select one, and then either command-click another, or in list/column view, Shift-click the item at the other end of the range you want to select. Alternatively, click on a spot in the screen and drag the cursor until all the files are selected.
    (114308)

Maybe you are looking for

  • Help - Safari Frames Question?

    I'm trying to open a document I sent to my gmail account. I'm using safari and when I open the doc it doesn't show up but instead says, "This page uses frames, but your browser doesn't support them." Same thing happens in Firefox. What's the deal? He

  • Any Standard FM  for material stocks on posting date  using  Tcode  MB5B

    Hi, I  need   Standard  FM  to get  material stocks on posting date  using   Tcode   :   MB5B Stock type  i am using  is  : Storage Location/Batch Stock the  Input   i am  providing  is    Material, Plant , Storage Location, selection  date From , se

  • Slow imac

    Suggestions for seems like a Imac that is slowing down.  Have 2 GB of ram and upgrading to 4 gb - max.  emptied cache and used disk utility to repair disk - no issues.

  • Is it possible to create LABViewApplication for our own Hardware?

    Hi everybody... We have designed our own Data Acquisition Hardware...earlier we were developing GUI application using VC++ for that hardware.. Is it possible to create GUI application for our own hardware?..(Serial port,parallel port,ethernet,TCP/IP,

  • CS3 to CS5, but need CS4 too

    I heard there is a free upgrade to CS5 if you purchase CS4 by July 31st. I haven't found any CS4 upgrades, does anyone know of a site selling the CS4 (with the chance to upgrade to CS5 for free)? Thanks for your time and input! -Teresa