Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Newbie help
16/06/2010
04:10
Avatar
ikim
Mexico
Member
Members
Forum Posts: 3
Member Since:
16/06/2010
sp_UserOfflineSmall Offline

Hi, all I'm trying to convert the example.php to java. I'm just trying to make and easy test without connecting my servlet to any database so im just sending the xml as text but it isnt working. I'veConfusedConfusedConfused try many ways to send the xml file as text but I could get this to work. My code is:

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            out.print("<?xml version='1.0' encoding='utf-8'?>\n"
                    + "<rows>\n"
                    + "<page>1</page>\n"
                    + "<total>1</total>\n"
                    + "<records>1</records>\n"
                    + "<row id='1'>\n"
                    + "<cell>1</cell>\n"
                    + "<cell>Mario</cell>\n"
                    + "<cell>29</cell>\n"
                    + "</row>\n"
                    + "</rows>");
        } finally {
            out.close();
        }
    }

What do im doing wrong? Any advice is welcome. Thanks in advance.

16/06/2010
04:48
Avatar
ikim
Mexico
Member
Members
Forum Posts: 3
Member Since:
16/06/2010
sp_UserOfflineSmall Offline

The error is stupid. I found the error:

response.setContentType("text/html;charset=UTF-8″);

has to be:

response.setContentType("text/xml;charset=UTF-8″);

and then magically works. Sorry for the post.

08/09/2010
17:07
Avatar
nalpolos
Member
Members
Forum Posts: 6
Member Since:
08/09/2010
sp_UserOfflineSmall Offline

In Java it would be

response.setContentType("text/xml;charset=UTF-8");

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information