Solved

Set userid in Java Code

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

Industry Leaders: 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

Title # Comments Views Activity
by zero exception 10 79
Running JavaFX on JDeveloper 12C 1 104
Given a github repo find email address of all collaborators in that repo 1 51
Java ArrayList and if statement 2 48
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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

731 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