Solved

Set userid in Java Code

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Updating Java 9 87
@SBGen Method 3 25
recursion example 16 69
sites similar to codingbat to improve coding hanson skills 3 23
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 step-by-step guide to install VisualVM launcher in eclipse.

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now