473,395 Members | 1,613 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,395 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 1519

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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.