?
Solved

Set userid in Java Code

Posted on 2011-03-14
4
Medium Priority
?
464 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 1336 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 1336 total points
ID: 35135491
Sorry i am not getting ur question can tell me clearly ?
0
 

Assisted Solution

by:djrikaz
djrikaz earned 664 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

764 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