Recuperar parametro da sessão na JSP

2 respostas
R

Olá, preciso recuperar um parametro que está na sessão coloca-lo em uma hidden...fiz desse jeito mas o resultado foi o erro abaixo... alguem sabe como posso fazer isso???
Grato.

Meu Codigo Atual:
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<html:html>

    <head        
        <title>Inserir nova operação</title>
    </head>
    
    <body>

    <jsp:include page="cabeçalho.jsp"/>
    
    <p align="center"> </p>
      
    <p align="center"><b><font face="Century Gothic" size="5" color="#FFFFFF">
      Cadastrar nova Operação:</font></b>
    </p>
     
    <p align="center"> </p>
    
    
    
    <html:form action="/salvaInsereOpe.do">
    
     <%= session.getAttribute("Id")%>
    
       [b]<html:hidden property="codUsuario" value = "<%= session.getAttribute("Id")%>"/> [/b]    
       Descrição: <html:text property="descricao"/>
       
      <html:radio property="tipoOperacao" value="1">Despesa</html:radio>
      <html:radio property="tipoOperacao" value="2">Receita</html:radio>
      
      <html:radio property="ativo" value="1" >Ativo</html:radio>
      <html:radio property="ativo" value="2" >Inativo</html:radio>

                                
                          
                                
    </span></font></b></p>
    <p align="center"> </p>
  
    
    
    
    
    
     <p align="center"><b><font face="Century Gothic"><html:submit>Cadastrar</html:submit></a></font></b></font></p> 

    
                             <%-- exibe os erros de validação --%> 
                                  </font></b>
                                <logic:messagesPresent>
                                    </p>
                                    <ul>
                                        <font color="red"><font size="2" face="Century Gothic">
                                        <html:messages id="error">
                                            <li>
                                            <p align="center"><bean:write name="error"/></li>
                                        </html:messages>
                                    </ul>
                                </logic:messagesPresent>
    
    </html:form>
       
    </body>
</html:html>

Meu Erro:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 32 in the jsp file: /insereope.jsp
Generated servlet error:
C:\Documents and Settings\Rodrigo\.netbeans\5.0\jakarta-tomcat-5.5.9_base\work\Catalina\localhost\StrutsFinanceiro\org\apache\jsp\insereope_jsp.java:133: cannot resolve symbol
symbol : method setValue (java.lang.Object)
location: class org.apache.struts.taglib.html.HiddenTag
_jspx_th_html_hidden_0.setValue( session.getAttribute("Id"));
^
1 error

2 Respostas

N

Olá, amigo!

Olha só, isso aqui não vai funcionar

Tente reescrever isso usando html mesmo, exemplo:

Não vejo como fazer isso de outra forma usando as tags do struts.

Se o bean todo estiver na sessão é possível utilizar o atributo scope=“session” na tag html:form. Exemplo:

<html:form action="minhaaction" scope="session">
....
</html:form>

Aí é só referenciar o atributo do bean.

Espero ter ajudado.

R

Ajudou muito…

Obrigado !!

Criado 19 de agosto de 2006
Ultima resposta 24 de ago. de 2006
Respostas 2
Participantes 2