Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Change a comment in a jsp file

 
Ayoub Zemmouri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
in a jsp page i have an image and comments below it, then a comment area (<form ..> <textarea>), i want my users to be able to change their comments, when they click the modifiy bouton (<a href=...>) i want the comment to apear in the comment area to be modify here's what i've tryed to do but not working

<%
"<a href='&?id_commentaire="+id_commentaire +"'><img src='images/mod.gif'></a>"+


String commm=request.getParameter("#id_commentaire");


if(commm!=null){

Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/atelier","root","");
ResultSet resultat = cnt.createStatement().executeQuery("SELECT * FROM comment WHERE id_commentaire='"+commm+"'");

String comen=resultat.getString("7");
out.print(
"<form action='/Atelier/CreerCommentaire' method='get'>"

+"<textarea name='comment' id='comment' value='"
+comen
+"'cols='25' rows='10'></textarea>"
+"</p>"
+"<input type='submit' id='sf_submit' value='Publier'>"
+"<input type='reset' id='sf_reset' value='Annuler'>"
+"</p>"
+"</form>"
);

}else{
for( int i = 0 ; i < listCours.size() ; i++ ){
out.print(
"<form action='/Atelier/CreerCommentaire' method='get'>"

+"<input type='hidden' name ='idCou' value='"
+listCours.get(i).getId_cour()
+"'>"
+" <p>"
+" <textarea name='comment' id='comment' cols='25' rows='10'></textarea>"
+"<p>"
+" <input type='submit' id='sf_submit' value='Publier'>"
+"<input type='reset' id='sf_reset' value='Annuler'>"
+" </p>"
+"</form>"
);}

}
%>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you generating HTML in Java strings inside (obsolete) Java scriptlets? The whole point of a JSP is to be able to create the HTML using template text.
 
Ayoub Zemmouri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i coied the code from a servlet ....... but i don't think that makes any diffrence it's still supposed to work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you copy code from a servlet into a JSP? That makes no sense at all. What are you actually trying to accomplish by doing that?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic