• Post Reply Bookmark Topic Watch Topic
  • New Topic

error with mvc application  RSS feed

Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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
  • 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?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!