Boa tarde a todos. To com uma duvida com blob e byte[], tenho q mostrar na jsp as informaçoes salvas num blob mas elas não tá sendo mostrada de forma correta com acentos etc. Já tentei algumas formas vista aqui mesmo no forum mas nada.
eu to salvando assim o blob
public String salvaAnotacoesAjax() throws Exception {
// Dados da Declaracao
String anotacoes = ServletActionContext.getRequest().getParameter("anotacoes");
String mes = ServletActionContext.getRequest().getSession().getAttribute("mesDeclaracao").toString();
String ano = ServletActionContext.getRequest().getSession().getAttribute("anoDeclaracao").toString();
String inscricaoEstadual = ExtractValue.getInstance().retiraMascara(
(String) ServletActionContext.getRequest().getSession().getAttribute("sInscricao"));
// Blob blobAnotacoes = new SerialBlob(anotacoes.getBytes());
byte[] byteAnotacoes;
Blob blobAnotacoes = null;
if (anotacoes != null && !anotacoes.equals("")) {
byteAnotacoes = anotacoes.getBytes();
blobAnotacoes = Hibernate.createBlob(byteAnotacoes);
}
DamDeclaracaoTO declaracaoTO = declaracaoServico.getPorInscricaoEstadualAnoMes(inscricaoEstadual, mes, ano);
declaracaoTO.setTxAnotacoes(blobAnotacoes);
// Dados da Declaracao
ServletActionContext.getRequest().setAttribute("retorno_ajax", declaracaoServico.salvaDeclaracao(declaracaoTO));
}
e to recupedando assim
String anotacao = "";
DeclaracaoDTO declaracaoDTO = new DeclaracaoDTO(idDeclaracao, "");
Collection<DeclaracaoDTO> clAnotacoes = new ArrayList<DeclaracaoDTO>();
if(declaracao.getTxAnotacoes() != null){
byte[] byteAnotacoes = declaracao.toByteArray(declaracao.getTxAnotacoes());
anotacao = new String(byteAnotacoes, "UTF8");
anotacao = anotacao.replace("'", "");
anotacao = anotacao.replaceAll("<br>", "\n");
anotacao = anotacao.replaceAll("<.*?>", "");
anotacao = anotacao.replaceAll(" ", "");
declaracaoDTO.setTxAnotacao(anotacao);
}
clAnotacoes.add(declaracaoDTO);
saida
PEND&Eci;rc;NCIA
deveria ser
PENDÊNCIA