• 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

HFSJ- Chap 3

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

I am doing the Mini MVC Tutorial mentioned in HFSJ..!
I have created the 2 java files and the Development architecture is as given in the book

1)C:\SCWCD-CX310081\MyProjects\beerv1\src\com\example\model\BeerExpert.java
2)C:\SCWCD-CX310081\MyProjects\beerv1\src\com\example\web\BeerSelect.java

This is the code I have written for 2 files..!

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

public class BeerExpert{

public List getBrands(String color)
{
List brands=new ArrayList();
if(color.equals("amber"))
{
brands.add(" Jack Amber");
brands.add(" Rose Amber");}
else{
brands.add(" Jail Pale Ale");
brands.add(" Gout Stout "); }
return(brands);
}
}
==============================================================

================== BeerSelect.java ===========================
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class BeerSelect extends HttpServlet{


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

String c=request.getParameter("color");
BeerExpert be=new BeerExpert();
List result=be.getBrands(c);

request.setAttribute("styles",result);
RequestDispatcher view=request.getRequestDispatcher("result.jsp");
view.forward(request,response);

}

}
========================================================

This is the error I am getting..!

C:\SCWCD-CX310081\MyProjects\beerv1\src\com\example\web>javac BeerSelect.java
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
BeerSelect.java:20: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors

I am not able to solve this prob since one day..! Can any one explain me y is this so ??

Please help me as this is frustrating me now..!
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nilesh,

I think that you are having the same problem as Satish Kesiboyana.
See this thread. Post back if I am wrong or that doesn't solve the problem.

Mat
 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nilesh ,
I think you have to set the classpath=C:\SCWCD-CX310081\MyProjects\beerv1\src\ . To solve this problem.


Rohan
 
Nilesh Raje
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes thanks a ton for your help..!
 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic