Solved

Reading ini file from JSP

Posted on 2000-04-23
8
1,456 Views
Last Modified: 2012-06-27
How do I read an ini file from a Java server page?
0
Comment
Question by:ssindhu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 

Author Comment

by:ssindhu
ID: 2742975
.
0
 
LVL 4

Expert Comment

by:jerch
ID: 2743118
Hi ssindhu...
I don't think it's good design for your jsp to read from an ini file. I suggest you to create an initializing servlet. The primary task of the servlet is to load all configuration data to the servlet context, which is like the global variables of servlet and jsp. These data are shared by different servlet and jsp.  Another alternative is to use the getInitParameter() method. Different web servers have different way of setting the init parameters.

best regards...
Jerson
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2743185
you can use java.util.Properties object which knows how to load & save it from configuration file ...
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Expert Comment

by:ovidiucraciun
ID: 2743319
or if you realy want an ini file, to provide a portable solution, use instead a ini file an XML file and use for parse it the last parser from sun
0
 

Author Comment

by:ssindhu
ID: 2743768
Thanks a lot Jerson your idea works..
Thanks to others also.
0
 
LVL 4

Expert Comment

by:jerch
ID: 2745909
you're welcome :)
0
 

Accepted Solution

by:
shgj earned 100 total points
ID: 2750526

Properties re=new Properties();
      InputStream is=getClass().getResourceAsStream (filename);      
      try
            {
            re.load (is);
            }catch (Exception e)
                  { e.printStackTrace ();}
      
      Enumeration en=re.keys ();
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2750552
WHOW WHOW whoooooooooooooooooooowwwwwwwwww
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question