Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HttpServletRequest

Posted on 2005-05-04
11
Medium Priority
?
164 Views
Last Modified: 2010-03-31
Firstly, sorry for this dumb question.

I'm writing a server-side web service and exposing a method where the client must enter username and password

So i've just done something simple like this:


public void getUserNamePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
   String userName = request.getParameter("userName");
   String password = request.getParameter("password");
}


I now want to test this to make sure the server-side is getting the values passed through - is there a way of testing this without going to loads of trouble of writing a client web service ?

Or is there a better way of getting username / password ?

Thanks for any help
0
Comment
Question by:plork123
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13927659
You can just use your browser to test it
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13927677
0
 

Author Comment

by:plork123
ID: 13928029


That doesn't work

Do i have to create a servlet?

I've created a web service from my java and generated a wsdl

Many Thanks
0
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!

 
LVL 86

Expert Comment

by:CEHJ
ID: 13928082
I thought that method was in a separate servlet, as opposed to the web service. If it isn't then you'll probably have to create a test client
0
 

Author Comment

by:plork123
ID: 13928208


cheers that's what i thought

I suppose i could rewrite the getUserNamePassword method to use

getUserNamePassword(String userName, Strign password) then the 'joe public' will know what to pass through

Thinking about it, i don't need HttpServletRequest/HttpServletResponse

Typing aloud !

0
 
LVL 11

Expert Comment

by:Manish
ID: 13932936
U need to write ur logic in doGet or doPost method in servlet .
Karan
0
 
LVL 1

Expert Comment

by:anindyabecs
ID: 13933341
Hi,
 If u'r writing a servlet do replace the logic of  getUserNamePassword in either doGet or doPost... It's always better to write the logic in doGet (as doPost is idempotent/and u'r dealing with login)..
                  Thanks -
                             Anindya
                       
0
 

Author Comment

by:plork123
ID: 13933586


thanks

I have my logic in a login hanlder that gets called when parameters are passed into the getUserNamePassword method

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 13933728
>>t's always better to write the logic in doGet (as doPost is idempotent/and u'r dealing with login)..

A POST request is *non-idempotent*. As a successful login has an effect, so is *it*.

You should actually use the security services of your container to deal with login. Look at 'realms' for your container. e.g. for Tomcat:

http://tomcat-docs.pil.dk/tomcat-docs/realm-howto.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month20 days, 18 hours left to enroll

810 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