Solved

Set userid in Java Code

Posted on 2011-03-14
4
445 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
  • 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

Independent Software Vendors: 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

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

685 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