I was wandering if there is an easy way to access a servlet which contains logic to jumble a word. I have the logic to jumble a word and would like to put this within a servlet.
I already have Tomcat set up on eclipse.
Within the android application will be an Onclick method and when clicked will jumble the word through the servlet. I have looked at HttpConnection but not sure how to implement this easily.
Any ideas on how to do this.
Thanks
Servlets are able to execute some Java code based on a specific HTTP request URL. You just need to map the servlet class in webapplication’s
web.xmlfile on a certain<url-pattern>(or when you’re already running a Servlet 3.0 capable container, using the@WebServletannotation). A kickoff example can be found in the servlets info page.Assuming that the servlet runs at http://example.com/context/yourservlet and returns the
Stringresult as plaintext like follows:All you need to do is to execute the HTTP request and obtain the HTTP response programmatically. Here’s a basic kickoff example using Android’s builtin HttpClient API (all obvious exception and resource handling aside):