Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it correct ???  RSS feed

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is is correct ???


public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException,IOException {
public void doGet(HttpServletRequest req, HttpServletResponse resp){
//resp.setContentType("text/html");
//PrintWriter out = resp.getWriter();
//out.println("Beer selection advice<br>");
String c = req.getParameter("Color");
//out.println("<br>Got beer color " + c);

BeerExpert be = new BeerExpert();
List result = be.getBrands(c);
//Iterator it = result.iterator();
//while(it.hasNext()){
//out.print("<br>Try : " + it.next());
//}

req.setAttribute("styles",result);

RequestDispatcher view = req.getRequestDispatcher("/jsp/result.jsp");
view.forward(req,resp);
}
}
}
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. This wont even compile.



You cant write the definition of a method inside another method.

It should be :
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Allright... Thanks...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!