• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is it correct ???

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
}
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Allright... Thanks...
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic