• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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..!
 
We noticed he had no friends. So we gave him this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic