Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

append a file  RSS feed

 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have this JSP that takes in the staff number and the password the user wishes for his intranet access. There are two things that has to happen
1. Append the password to .htpassword file
2. Append the staff number to .htgroup file.

The first one i have done, but for the second one the .htgroup file is like this:
1234,1235,1237,1238
Now if i have to insert the staff number 1236 ---- it has to go between 1235 and 1237 in the .htgroup file.
I know how to read the .htgroup file using Buffered Reader, but how would i go to the specific line and append that staff number in the right place???

How would i do that..??? please can some help.!!!

Thanxs.
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, the numbers in the .htgroup file are seprated with space and not with commas..

so it would be 1234 1235 1237 1238, so after adding the number 1236, the file would be 1234 1235 1236 1237 1238

Thanxs
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 Read everything into a String
2 Split String on Whitespace into an array
(org.apache.commons.lang.StringUtils)
3 add your new entry to String Array
4 Sort Array (http://www.javaalmanac.com/egs/java.util/coll_SortArray.html)
5 Join Array
(org.apache.commons.lang.StringUtils)
6 Write out String

BUT

Did you give the subject Multiple Users a thought?

What happens when two users do this thing. I think that is going
to be the tough part.

Have fun,

J.
[ July 15, 2005: Message edited by: Jeffrey Spaulding ]
 
Rekha Pande
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Jeffrey,
Did you mean that,
1) 2 users at the same time would submit the request for creating new accounts? OR
2) 2 staff numbers and passwords are supplied at the same time..!!!

Thanks
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1) 2 users at the same time would submit the request for creating new accounts?

so ? that wouldnt be an issue


2) 2 staff numbers and passwords are supplied at the same time..!!!


Thought that was your original question <quote>I have this JSP that takes in the staff number and the password the user wishes for his intranet access
</quote> ?

cheers,
ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!