send login and password to tomcat

Discussion in 'Java' started by seb, Sep 29, 2003.

  1. seb

    seb Guest

    Hello! I want to protect a directory in my Web Application. Protected
    directory: http://localhost:8080/sample/protected/ I did the necessary
    things with the „tomcat-user.xml" and „web.xml" file. It works fine.
    If the user wants to access a file in the protected directory, a
    dialog appears and asks for login and password. With the right
    login/password the user can access the files in this directory. But
    what I have to do, if I want to access a file in this directory from a
    Java program? Naturally a normal access returns a 401 Error code. How
    can I send login/password from a Java program? I do not want, that a
    dialog box appears.

    Thanks

    Sebastien
     
    seb, Sep 29, 2003
    #1
    1. Advertising

  2. seb wrote:

    > Hello! I want to protect a directory in my Web Application. Protected
    > directory: http://localhost:8080/sample/protected/ I did the necessary
    > things with the „tomcat-user.xml" and „web.xml" file. It works fine.
    > If the user wants to access a file in the protected directory, a
    > dialog appears and asks for login and password. With the right
    > login/password the user can access the files in this directory. But
    > what I have to do, if I want to access a file in this directory from a
    > Java program? Naturally a normal access returns a 401 Error code. How
    > can I send login/password from a Java program? I do not want, that a
    > dialog box appears.
    >


    Two ways.
    1 - put the userid/passwd into the URI. EG
    http://user:passwd@localhost:8080/sample/protected

    2 - Put the userid/passwd into the Authorization HTTP header. Study the
    HttpURLConnection API to find out how.
     
    David Zimmerman, Sep 29, 2003
    #2
    1. Advertising

  3. seb

    seb Guest

    seb, Oct 16, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    8,015
    craftykitty
    Aug 27, 2007
  2. pj
    Replies:
    2
    Views:
    1,961
  3. AAaron123
    Replies:
    2
    Views:
    2,295
    AAaron123
    Jan 16, 2009
  4. AAaron123
    Replies:
    1
    Views:
    1,372
    Oriane
    Jan 16, 2009
  5. Peter van der Veen
    Replies:
    1
    Views:
    163
    Peter van der Veen
    Aug 20, 2003
Loading...

Share This Page