This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have David & Dawn Griffiths on-line!
See this thread for details.
Win a copy of Head First Android this week in the Android forum!

Sneha Kulkarni

Greenhorn
+ Follow
since Aug 23, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sneha Kulkarni

Hi,

I checked the past reply,i tried everything they have mentioned.
I changed my import statement as-import com.example.model.BeerExpert;
I created the src directory and tried to compile from src.
Then also its giving the same error.

I tried to compile from the below mentioned path

D:\dir\apache-tomcat-5.5.26\webapps\ram\WEB-INF\classes\com\example\web>javac BeerSelect.java

Thanks in Advance
Sneha
Hi All,

I am trying to run the example given in the third chapter of the HFSJ..
1)I created the HTML and DD...and run the program .
Executed perfectly.
2)Created the First Version of Servlet BeerSelect.java and executed perfectly.
3)Created the BeerExpert.java,compiled and copied a copy of .class file of BeerExpert in com/example/model packege.
4)Modiefied the first verion of servlet to second version as below

//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 IOException,ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Beer Selection Advice <br>");
String c = request.getParameter("color");
//out.println("<br>Got beer color " +c);

BeerExpert be = new BeerExpert();
List reult = be.getBrands(c);
Iterator it = result.iterator();
while(it.hasNext())
{
out.print("<br>try: "+it.next());
}


}
}

And BeerExpert.java is as below

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("Red Moose");
}
else
{

brands.add(" Jial Pale Ale");
brands.add(" Gout Stout");
}
return(brands);
}
}

5)But when i tried to compile the BeerSelect.java, i am getting an error
As-
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
So what is the mistake i have done here..please anybody suggest me ,what i have to do to execute it correctly.

Thanks in advance
Sneha
Hi,

Can anybody please explain me about Assertions?

Thanks
Sneha :roll:
Hi Raghavan

Thank you!,i understood the instanceof now.

Regards
Sneha
Hi Raghav

If you dont mind,can you please explain me in brief?

Thanks
Sneha

Originally posted by Raghavan Muthu:


"instanceof" operator is used to determine the object type at runtime.

You can take a decision based on the actual object so as to invoke its functionality.

A sample code would be:



Note:

  • You can use only OBJECTS to check using instanceof operators as the term 'instance' indicates


  • you can use the fully qualified classname in the checking as 'java.lang.String' instead of 'String'. This will be helpful to use the classes-happen-to-have-same-name (for example, java.awt.List and java.util.List)


  • the instanceof operator returns true for the object when compared against any of its compatible and/or super class(es). Any object when compared against java.lang.Object would return true always


  • Does that help you?

    [ September 10, 2007: Message edited by: Raghavan Muthu ]

    Hi,

    Can anybody please explain me about instanceof operator,how it is used etc?

    Thanks in advance

    Sneha
    Hi,

    Can anybody please provide me some URL's related to bit shifting operation?
    I mean containing examples related to bit shifting etc.

    Thanks
    Sneha
    Thanks! for suggesting me regarding the study material.

    Please anybody explain me the fallowing increment operator example?

    class Increment
    {
    public static void main(String []args)
    {
    int i=0;
    i=i++;
    i=i++;
    i=i++;
    i++;
    System.out.println("i= " +i);
    }
    }
    Hi,

    I am planning to Take SCJP1.5,so can please help me regarding this?
    Which book i have to refer and how i have to prepare for the exam?

    Thanks
    Sneha