I need to capture an input name, query the database, and return the result in a jsp page. I want to show the result in a short section of the JSP page, in case I mix the JSP page text with the result I want to capture.
jsp page with input
Nome: <input type="text" name="nome" />
<br/>
Cpf: <input type="text" name="cpf" />
<br/>
<p>
<input type="submit" name="enviar" value="Enviar" />
<input type="reset" name="limpar" value="Limpar" />
</form>
</div>
</body>
List
PrintWriter out = response.getWriter();
SessionFactory factory = new Configuration().configure().buildSessionFactory();
Session session = factory.openSession();
session.beginTransaction();
List<Pessoa> listForm = new ArrayList<>();
listForm = session.createQuery("from Pessoa where cpf like '%"+cpf+"%' and nome like '%"+nome+"%'").list();
int tamanho = listForm.size();
for(int i=0;i<tamanho;i++){
Pessoa pessoa = listForm.get(i);
out.println(pessoa.getId()+" - "+ pessoa.getNome());
}