Hi Everyone.
I make an aplication with netbeans, struts and tomcat as server.
When i run it locally this work perfect. But when i deploy the application in other machine it not work correctly.!
The application show a list the people, if you want to change the name you can do it, but if the name have accents it is saved in database with wrong caracters!!!
I can not understand why work perfectly locally but not work in other servers(other machines).
I put in jsp code:

<%@ page language="java" contentType="text/html;charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>

Thanks all.
Anyquestion please let me know.

PS: sorry if my english is not good (is not my mother language)

Recommended Answers

All 4 Replies

Member Avatar for LastMitch

@jhonilson

The application show a list the people, if you want to change the name you can do it, but if the name have accents it is saved in database with wrong caracters!!!

There's nothing wrong with your code:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

Is there more code? That 1 line doesn't solve the issue you are having.

Maybe if you include this:

<?xml version="1.0" encoding="UTF-16" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" >
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" />
<jsp:directive.page pageEncoding="ISO-8859-1" />

and also if you set your metatag like this:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

Now put it together it should look like this:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<?xml version="1.0" encoding="UTF-16" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" >
<jsp:directive.page contentType="text/html;charset=ISO-8859-1" />
<jsp:directive.page pageEncoding="ISO-8859-1" />

Thanks for the reply.
my web.xml begin with:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

in my jsp i put this for manage the accents without problems:

        function reasignar(id,txt){
            var tiempo = new Date();
            var log=document.getElementById(txt).value;
            var i = document.getElementById(txt).selectedIndex;
            var esp=document.getElementById(txt).options[i].text;
           var link = encodeURI('/reasignar.do?id='+id+'&log='+log+'&esp='+esp);
         // var link = '/reasignar.do?id='+id+'&log='+log+'&esp='+esp;
            $.ajax({
                type: 'get',
                dataType: 'html',
                url: '<%=url%>'+link+"&tiempo="+tiempo.getTime(),
                async:false,
                success: function() {
                    $('#dialog').dialog('close');
                }
            });
        }

you can see the diference in the commented line. I use "encodeURI".
Actually the problems is in the remote server. The application work fine locally but i dont understand why it work bad remotely.!
Maybe something is not compatible with the remote tomcat or the remote tomcat have some differences in the settings ?
The code is extremely long therefore i can not post it here.
I had download the remote tomcat to my local machine, i run it and deploy the application and it work bad still.!

Thank you.

Member Avatar for LastMitch

@jhonilson

I had download the remote tomcat to my local machine, i run it and deploy the application and it work bad still.!

Did you follow exactly how it looks here:

http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant

So your header in XML looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Did you add these lines too:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

Hi Lastmitch
Sorry for delay answer.
I had solve the problem. I tried the application in another tomcat and it work!
Why it work here and not there is a mistery still.
And Yes, i wrote the lines that you indicate me in you answer. I always put these in my codes.!
Modify the remote server is a risk when you are running other applications on it. Thanks God we have many tomcat installed in diferent machines and we can try.
If i discover the cause i will explain it here, dont worry.
Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.