Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!

Ilakya Mukunth

Ranch Hand
+ Follow
since Mar 13, 2012
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ilakya Mukunth

I have an issue in the same example. I created two files (shown below). But the only changes I made in the directory structure is that, I removed the com.example. Please look at my directory structure below. I am unable to import the model package from
package model;
import java.util.*;
public class BeerExpert {
public List getBrand(String color) {
List brands = new ArrayList();
if (null != color && color.equals("amber"))
brands.add("Jack Amber");
brands.add("Red Moose");
brands.add("Jail Pale Ale");
brands.add("Gout Stout");
return brands;
C:\ProjectWork\Beer>javac -classpath "C:\Program Files\Tomcat\lib\servlet-api.jar" -d classes src/model/
Note: src\model\ uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

package web;
import model.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class BeerSelect extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
String color = request.getParameter("color");
out.println("Beer selection <br> color is: " +color);

C:\ProjectWork\Toys>javac -classpath "C:\Program Files\Tomcat\lib\servlet-api.jar" -d classes src/web/
src\web\ error: package model does not exist
import model.*;
1 error

Please find my directory structure in the attachment.
Kindly let me know your views ASAP.
Thanks in advance,

7 years ago
This youtube video shows how to configure the Tomcat
7 years ago
Thank you very much.
8 years ago
1. I stopped the Tomcat in Eclipse IDE.
2. StartedTomcat manually in Terminal
3. Tried launching Http://localhost:8080 from eclipse browser, it worked fine.
4. right clicked on JSP page->Run As->Run on Server-> It shows the error message that the port is already in use.
This is because I have already started tomcat from terminal and it is up and running.
5. I did run tomcat from terminal as you said, but i do not know how do i run the JSP pages in eclipse without tying to run tomcat from eclipse IDE.
my questions and doubts may sound silly, but i am new to this technology and i try to learn by myself.
if you could help me to resolve the conflict and help me to set up eclipse IDE with proper setup, it would be a great help.
Thanks for your time.
i find a strange scenario.

It displays the error message shown above when i click ProjectName->Run As-> Run on Server.
But if i click on the particular JSP file and -> Run As-> Run on Server it works fine.
Really do not know how to fix it. Please help me to go forward.

Thanks for your input.
I am unable to run tomcat server 6 neither from my eclipse nor from my browser. When i try to enter http://localhost:8080, it says "description The requested resource (/) is not available.". I have included the screen shot with his message. I am using mac 10.8. I am very beginner to Eclipse and Servlets. Just started the configuration and tried to run Hello World. And nothing worked out. I am very discouraged to pursue my beginning with Servlets. If you help me to resolve the issue, it would be of GREAT help. :-(

Thanks in advance,
Can you please tell me how to uninstall tomcat on mac os (10.8)?
8 years ago

Himai Minh wrote:

Ilakya Mukunth wrote:1. can we assign a one type of primitive variable to another primitive variables?
public class PrimitivesAssign

public static void main(String[] args)
PrimitivesAssign a = new PrimitivesAssign();

void test()
byte b=10;
short s =10;
char c =10;
int i =10;
long l =10;
float f =10,ff=10.0f;
double d = 10;
d=f; d=l; d=f; d=i; d=s; d=b; d=c;
f=l; f=i; f=c; f=s; f=b;
l=i; l=c; l=s; l=b;
i=c; i=s; i=b;


are my assignments valid? I compile this code. it works fine. no compile time error

2. can we assign a one type of primitive array reference variable to another primitive array reference variables?
public class PrimitivesAssign

public static void main(String[] args)
PrimitivesAssign a = new PrimitivesAssign();


void test2()
byte b[] = new byte[4];
short s[]= new short[4];
char c[]=new char[4];
int i[]= new int[4];
long l[]=new long[4];
float f[]= new float[4];
double d[] = new double[4];

//d=f; d=l; d=f; d=i; d=s; d=b; d=c;
//f=l; f=i; f=c; f=s; f=b;
//l=i; l=c; l=s; l=b;
//i=c; i=s; i=b;
The commented lines did not compile. Can anyone explain the reason why?

question 1:
assiging a smaller variable to a bigger variable is ok. For instance, assigning an integer to a double is ok. A double can hold 64 bits. An integer is almost 32 bits.
But if you assign a double to an integer without casting, it won't compile. A 32-bit integer cannot hold a 64-bit double.

question 2:
assigning a type to a different type is not ok. double[] is an object type. int[] is another object type.
Just like Double d = new Integer(); It is a type mismatch error.

class MWC118 {
public static void main(String[] args) {
byte[] b = {'a', 'b', 'c'}; //1
byte b2 = 'a'; //2
String s1 = new String(b); // 3
String s6 = new String(b2); // 4
How can you assign char to an byte? byte is 8 its and char is 16 bits. Can you explain. The line 4 will produce the compile time error
I tried to compile the following code and it just compiled fine. but i do not understand the meaning of these constants.
1. char c ='\u0061', c1='\61';
2. System.out.println(c + " " +c1); // a 1

1. float f1 =\u0030;
2. System.out.println(f1); // 0.0

how can we assign unicode constants to float?
int[][] a = {{1,2},{0,1,2},{-1,0,2}}; // 1
Object[] obj = (Object[])a.clone(); // 2
int [] obj1 = (int[])a.clone(); //3
The line 1 and 2 compiles fine. If I add line-3, it does not run. Can anyone explain me why?
Check out the code below:

int m1(int i) {System.out.println(i + ","); return i;}

void test9()
int i = 0;
i = i++ + m1(i); System.out.println(i);
Output is:

I check the operator precedence in this website:

I expected the output to be 0,1.
does i++ evaluated before calling method m1()?
Can anyone help?

Tse Wu wrote:I think it is a safe bet that you are better off reading the entire K&B book, the only thing that was not on the exam for me was serialization.

Even bitwise operator and shift operators are not included in ocpjp. am i right?

Jeanne Boyarsky wrote:This would probably be a good time to make sure you are aware that ~ is not on the exam. Bit operations were removed from the SCJP.

I believe even the shift operators are removed from the OCPJP. is it so?

Henry Wong wrote:

Jeet Jain wrote:Ohh thank you. But then that means that precedence(parentheses) has no relevance since it is going to be evaluated left to right anyways? And doesn't the NOT(!) operator have higher precedence than || and &&? so first the b2 operand should be evaluated, right?

Well, I wouldn't say no relevance, as precedence affects what the logical (short-circuit) operators, which in turn, does affect the order of evaluation (to stop evaluating that is).


The following,
boolean a,b,c;
boolean x = (a = true) || (b = true) && (c = true);
System.out.println(a +" "+b +" "+c +" "+x);

true false false true

I read that the logical operator's precedence is && ^ and ||
I really do not understand when do I have to apply the precedence of && and ^
Can you help me?