wood burning stoves 2.0*
The moose likes Web Services and the fly likes accessing user input from a web page through a web service Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Web Services
Bookmark "accessing user input from a web page through a web service" Watch "accessing user input from a web page through a web service" New topic
Author

accessing user input from a web page through a web service

ratna sargurp
Ranch Hand

Joined: Jan 12, 2010
Posts: 32
I am fairly new to java and am trying to code a web service. I have the main logic written and tested locally by hardcoding some values. Now I am trying to do an end to end testing. Here is my scenario:
There is a web application that will be the consumer of my web service. This web app sends me user input through a web page. I read the input, perform my magic, and return the result string back to the web page.

Here is my understanding so far of what I need to do:

1) In order to receive the information from the web page, I need a servlet that gets the parameters from the webpage through request.getParameter on the doGet method. Correct?
2) I then pass this information to my java class that has all the logic.
3) The java class then needs to return this back to the web page.

The method that received the input strings and returns a string has been declared as the web service.

Is this the right understanding? I am kind of stuck at step 3. How do I return this information back to the web page?

Can anybody tell me if I am going in the right direction and guide me?
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 637
The method that received the input strings and returns a string has been declared as the web service.


if you have to invoke this method as webservice then you don't need servlet, simply mark this method as one of Rest methods (POST or GET) and invoke with valid url.

If you follow the approach that you have mentioned then there is no need to mark the method as web service as its not a webservice call its simple servlet call that invoked a method in different class in its doget/post method.

-P


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Is your web page in the same web app as the web service method? If so, then it's not really a web service, is it?

If not, and the web service result is to be sent back to the still-loaded web page, then the web page needs to use Ajax, not a form submit. A form submit will unload the web page.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
ratna sargurp
Ranch Hand

Joined: Jan 12, 2010
Posts: 32
Thank you for all your replies.

No the web page is not in the same web app as the web service method. It is an external web page.

Is there any way to simulate this and test my web service manually even before that web page uses my web service?
ratna sargurp
Ranch Hand

Joined: Jan 12, 2010
Posts: 32
I found that SOAP-UI is a wonderful solution to test web services.

Thanks for all your help!
 
GeeCON Prague 2014
 
subject: accessing user input from a web page through a web service