1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| @WebServlet( "/Test2" )
public class Test2 extends HttpServlet {
public static final String ATT_DOCUMENTS = "documents";
public static final String VIEW_SEARCH = "/WEB-INF/pageTableau.jsp";
protected void doGet( HttpServletRequest request, HttpServletResponse response )
throws ServletException, IOException {
// TODO Auto-generated method stub
{
// Creation d'un objet document1
Document doc1 = new Document();
doc1.setAuteur( "Bob Marley" );
doc1.setID( 2134 );
doc1.setReference( "1232 - 2343 34" );
doc1.setResume( "L'histoire d'un chanteur/musicien " );
// Creation d'un objet document2
Document doc2 = new Document();
doc2.setAuteur( "Molière" );
doc2.setID( 324 );
doc2.setReference( "34534 - 3543 14" );
doc2.setResume( "Un écrivain" );
// Creation d'une arrayList de document
ArrayList<Document> documents = new ArrayList<Document>();
// Ajout des documents dans la liste
documents.add( doc1 );
documents.add( doc2 );
request.setAttribute( ATT_DOCUMENTS, documents );
this.getServletContext().getRequestDispatcher( VIEW_SEARCH ).forward( request, response );
}
}
} |
Partager