Win a copy of Rust Web Development this week in the Other Languages forum!

jnrohit Jain

+ Follow
since Sep 08, 2016
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 jnrohit Jain

In order to implement MVC model I created file in ~/Controller directory. If I convert this file into .jsp and move it into ~/jsp directory then it won't solve the purpose of MVC model. What is the way to call class file of located in ~/Controller directory?

8 months ago
I am creating a simple Java web application "Registration Form". I am using following hardware and softwares:
Machine: Amazon Linux 2 EC2 Instance.
Java version: 1.8.0_282
Maven: 3.6.3
Apache Tomcat: 7.0.76
Servlet: 3.1.0 (In pom.xml group ID: javax.servlet, artifactId: javax.servlet-api)
Note: I am not using any IDE. I am writing code using Linux vim utility.

I am following below steps in order to create Java web application project "Registration Form".
1. Create project directories and pom.xml using

2. Directory structure looks like below:

3. I have added servlet dependency in pom.xml
4. Write code in pom.xml, index.jsp, myStyle.css, register.jsp,, web.xml. Code is shown below.
5. When I execute "mvn clean package" it build the project successfully. After deployment to Tomcat server it display the register.jsp page correctly. After fill data and press submit button it throws error "HTTP Status 404 - /JavaWebApplication/jsp/guru_register". I do not understand why it is looking guru_register page in /jsp folder. Can you please see the code and help me to find the issue?

Note: Due to some limitation I cannot use Windows OS and any IDE so I am using Amazon Linux EC2 for practice. Thank you!






8 months ago

When I cast a class into an unrelated class then it gives me a compile time error (incompatible types) and when I cast a class into an unrelated interface it gives me a runtime exception (classCastException). Why casting to interface not giving compile time error?

4 years ago
I have following piece of code:

ClassA in C:\java

ClassB in C:\java

How to import ClassA in ClassB so ClassB compile and execute successfully? Do I need to use classpath to compile and execute ClassB code?
4 years ago
Below is Question 14 from "Jeanne Boyarsky" book Assessment Test at page xxxvii. I do not understand which object can replace line 5 (blank line) to compile and execute code successfully.

Q.14. Assuming we have a valid, non-null HenHouse object whose value is initialized by the
blank line shown here, which of the following are possible outputs of this application?
(Choose all that apply)

A. The code will not compile because of line 6.
B. The code will not compile because of lines 7–8.
C. The application will compile but not produce any output.
D. The application will output Cluck exactly once.
E. The application will output Cluck more than once.
F. The application will compile but produce an exception at runtime.

Correct Answer: DEF

Got it. Thanks :-)
4 years ago
As per the rule, I was expecting Java to promote the char to an int before the arithmetic operation. I was expecting output number 3 (1 + 2).
4 years ago
Following is the Numeric Promotion Rule in "Jeanne Boyarsky" book at Page #56:
"Smaller data types, namely byte, short, and char, are first promoted to int any time they're used with a Java binary arithmetic operator, even if neither of the operands is int."

a1 : 99

Why c1 and c2 not promoted to int before binary arithmetic operator applied?
4 years ago
In this example line #5 assigns value of a (i.e. 1) to c first and then perform unary operator ++ and save new value in variable a. At line #10 it assigns value of "a" (i.e. 1) to variable "a" first and after that I hope it will perform unary operator ++ but I do not understand where that new value get stored if not in variable "a".

value of c: 1
value of a: 2
value of a: 1
4 years ago
Wow.... Good to know that..
4 years ago
Following code will not compile because of line 4 and 6. I was expecting line #7 will also give compile time error because it is having long (64 bit) value which is bigger than float integral value 32-bit. Why line #7 working correct?

4 years ago

Does this book contain three sets of practice exam test? OR I should purchase separate book (like "OCA / OCP Practice Tests: Exam 1Z0-808 and Exam 1Z0-809") for practice exam.

OCA / OCP Java SE 8 Programmer Certification Kit: Exam 1Z0-808 and Exam 1Z0-809 1st Edition
by Jeanne Boyarsky   (Author),    Scott Selikoff   (Author)

4 years ago
Why following piece of code throwing compiler error?


C:\Practice>javac error: non-static variable super cannot be referenced from a static context
1 error
5 years ago
Take a look at the following code sample from "Jeanne Boyarsky" OCAJP book:



Following is the statement written in this book and I do not understand the highlighted part:-

The second method, eat(), is overridden in the subclass Eagle, since the signature is the
same as it is in the parent class Bird- they both take a single argument int. Because the
method is being overridden, the return type of the method in Eagle must be a subclass of
the return type of the method in Bird
. In this example, the return type of void is not a sub-
class of int. therefore, the compiler will throw an exception on this method definition.
5 years ago