Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a property file using JSP  RSS feed

 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Fedora Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Why my below code does not create a property file.
What code I'm missing please help.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Fedora Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh Sorry I posted Here.

I want it in JSP section.

How can I delete this and repost.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To move a post, you ask a staff member to move it for you. However, in this case, your post really has nothing to do with JSP. It's just Java file I/O. so it's been moved to the I/O forum.


 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except that you forget flushing and closing your FileWriter, I see no big problems. What's going wrong? Can't you find the file? If so, print the results of outputFile.getAbsolutePath() to see where it is located.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Fedora Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob.

I am amazed that it creates file at C:\WINDOWS\system32\pass1.properties

How can I program to create pass1.properties file at my deployed modules WEB-INF/classes/ folder.

I dont want to give an absolute path in code.

It does not seems to write the values given in input form also.

Please HELP.
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use ServletContext's getRealPath method:

application.getRealPath("/") will be mapped to <TOMCAT_FOLDER>/webapps/<WEBAPP>
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Use SerlvetContext getRealPath() for your class and use it.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Fedora Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh Great!! Thanks Rob.

It creating a new file at classes folder but it seems its not writting the values i give in the form i.e username and password.
what could be the issue.

In my form I am submitting to it own input jsp i have below code i.e
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You still need to close() your writer.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Fedora Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Rob For the QUICK Help Extended.
Now tis working like charm
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!