• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

error with mvc application

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI ,

I am trying to write a very very simple MVC application....

Here I have written a view , a model and a controoler..

I am trying to instantiate model from my controller but am getting error at the same

line where i am instantitaing..

-----------------------------view -------------------index.jsp




<form method ="post" action ="selectionBeer.do">


<select name ="color" size ="1">


<input type ="submit">


-------------------Controller ---------------BeerSelect.java----------------

package com.example.web;

//import com.example.web.BeerExpert;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import java.util.*;
import com.example.model.*;

public class BeerSelect extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request ,
HttpServletResponse response)throws IOException,ServletException {

PrintWriter out = response.getWriter();
//out.println("<b>hello selected");

String c = request.getParameter("color");

out.println("<b>color is hello"+c);

BeerExpert be = new BeerExpert();

out.println("Hello "+be);
/*List <String> result = be.getBrands(c);

Iterator <String> it =result.iterator();

while (it.hasNext())
out.print(" Try this Beer : " +it.next());




----------model --- BeerExpert.java-----------------

package com.example.model;
import java.util.*;

public class BeerExpert{
public BeerExpert()

System.out.println("hello Inside constructor");

public List <String> getBrands (String Color)

List<String> brands = new ArrayList<String>();
if (Color.equals("amber"))
brands.add("Jack amber");
brands.add("Red Mose");
else {

brands.add("jail PAle ale");



Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use code tags when posting code.

And tell us the details - for example, what exactly is the error you get, and when?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic