How to return a string back to a client Via HttpServletResponse?

Joined
Jan 2, 2009
Messages
1
Reaction score
0
Hi everyone, i am facing a problem of how to sent a string from my HttpServlet back to my mobile client.

when my mobile client call my Servlet's url, my online servlet can receive it's request. And then my servlet should return a string back to this mobile client.
Can anyone point me a way to do it?

For myself, I am come out the following codes, but i am not sure is it works.
Code:
protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException 
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("My String ")
    }

Thanks For Any Helps~:veryprou:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top