473,421 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

How to read text file via JSP

Hi,

i am unable to read txt file from jsp. i am getting null pointer exception.

path of jsp: WEB-INF/views/main.jsp
path of txt: WEB-INF/views/ServerDetails.txt

Following is the code...please suggest where can i make changes to solve the issue.
Expand|Select|Wrap|Line Numbers
  1. <%
  2. BufferedReader input = null;
  3. String serverName;
  4. try {
  5.     input = new BufferedReader(new FileReader("ServerDetails.txt"));
  6. } catch (FileNotFoundException e1) {
  7.     e1.printStackTrace();
  8. }
  9. String line = "";
  10. try {
  11.     while ((line = input.readLine()) != null) {
  12.       System.out.println(line);
  13. %>
  14. serverName=request.getServerName();
  15. <%      if(line.equalsIgnoreCase(serverName)){
  16. %>
  17. <H4 align="right">
  18.    out.println("you have entered into primary server");
  19.  </H4>
  20.  
  21. <%      }else{%>
  22. <H4 align="right">
  23.   out.println("you have entered into secondary server");
  24. </H4>
  25. <%      }
  26.  
  27. }
  28.     input.close();
  29. } catch (IOException e) {
  30.     e.printStackTrace();
  31. }
  32.  %>
  33.  
regards,
rama
Oct 14 '10 #1
0 1527

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Job Lot | last post by:
How can I find path of windows folder using vb.net? It could be winnt or windows depending upon the os. System.Environment.SpecialFolder enumeration does not have a constant for windows folder.
3
by: Bill | last post by:
I need to find the path to my EXE. Is there a better way than: string exePath = Assembly.GetExecutingAssembly().CodeBase; Thanks. -- ..Bill.
1
by: Steve | last post by:
Hi all, I am referring to this article in MSDN : http://msdn.microsoft.com/library/en-us/secauthn/security/logonuser.asp While creating folder on the remote machine, we are specifying the UNC...
2
by: Shimon Sim | last post by:
I have web project that includes few sits that must share some pictures. The project has following structure Root - just a folder with solution files - this is on IIS regular folder Site 1 - web...
3
by: FE | last post by:
Guys, I need to create a program (VB) to dump the outlook profile of a user. By dump I mean a report such as : User : Mr A * Folder 1 : exchange mailbox * Folder 2 : c:\data\pst1.pst *...
1
by: FE | last post by:
> Guys, > > I need to create a program (VB) to dump the outlook profile of a user. > > By dump I mean a report such as : > > User : Mr A > * Folder 1 : exchange mailbox > * Folder 2 :...
0
by: John Doe | last post by:
Windows XP Visual Studio 2003 NET Visual C++ When I tried to run without debugging, I get a message that says it can't find a path. The path did exist on my computer. I cannot find the path...
4
by: suresh_punniyakkodi | last post by:
Hellow Friends, Now, i am developing one project. I want one help,, How to find path in VisualBasic. I am created exe file in VisualBasic and...
3
by: moongirl | last post by:
Part of an application I am building includes a button which the user can click on to view a PDF file in Acrobat Reader, using the following code: System.Diagnostics.Process.Start(@"C:\Program...
6
by: HONOREDANCESTOR | last post by:
Suppose I have a dll which might be installed in the directory c: \MyClass\. I want to be able to find the path of this dll from within the dll. In other words, I want a function that can return...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.