Solved

Set userid in Java Code

Posted on 2011-03-14
4
457 Views
Last Modified: 2013-11-24
I have a java application that is connecting to a URL and downloading files using the following code:

HttpURLConnection connection = (HttpURLConnection) url;

Several different users will be using this application, however,  I want the URL connection to think a specific user is calling it each time.  Is there a way to change userid in the Java code so that it appears as though a specific user is running the application?

Thank You
0
Comment
Question by:VBStudent
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 334 total points
ID: 35131073
for connection you need user name nad password right ??


HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection .setRequestProperty("UserName", userName);
  connection .setRequestProperty("Password", password);
0
 

Author Comment

by:VBStudent
ID: 35131255
The connection does not require a user name or password input.  The userID is obtained by the website from the network connection.  In other words, if I am logged into the network as user = 123456, then the website is picking that user id from the network connection.  
0
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 334 total points
ID: 35135491
Sorry i am not getting ur question can tell me clearly ?
0
 

Assisted Solution

by:djrikaz
djrikaz earned 166 total points
ID: 35144535
you can have log just before the Http call which user is calling the service.
you can associate some additional information sessionid,etc.


any way your question is not clear, kindly brief with the steps your trying to do with this task?
 
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.

696 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