Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

append a file

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic