Solved

Reading ini file from JSP

Posted on 2000-04-23
8
1,439 Views
Last Modified: 2012-06-27
How do I read an ini file from a Java server page?
0
Comment
Question by:ssindhu
  • 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 88
javap not working 8 44
how to install java on RHEL image on EC2 4 27
Desingning Refactoring existing code 2 24
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

770 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