Bom dia pessoal!!!
Como uso o atributo de um servlet em um jsp?
package beans.com.opm3;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class proximaServlet extends HttpServlet {
// pergunta
private String dominio;
private String quantidade;
private String descricaoPergunta;
private int codigoPergunta;
private int idPergunta;
private int tipoQuestionario;
// resposta
private ResultSet rs;
// caminho
private String caminho;
public void service(HttpServletRequest req, HttpServletResponse res){
try {
questBd bd = new questBd();
quantidade = bd.retornaTotalDeQuestoes(idPergunta);
rs = bd.retornaPergunta(idPergunta);
while(rs.next()){
descricaoPergunta = rs.getString(“desc_per”);
dominio = rs.getString(“desc_domi”);
idPergunta = rs.getInt(“opm3pergunta”);
codigoPergunta = rs.getInt(“codi_perg”);
}
//caminho = “/questionario.jsp”;
caminho = “/questionario.jsp”;
RequestDispatcher rd = req.getRequestDispatcher(caminho);
rd.forward(req,res);
} catch (SQLException e) {
e.printStackTrace();
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Desde já fico grato.