Rafi Fareen

Ranch Hand
+ Follow
since Aug 28, 2009
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 Rafi Fareen

Hi guys,

I have passed the SCWCD 1.5 certification exam with 81% score.

I have read the book HFSJ twice, but the most important factor that helped me with exam was the mock exam.
You gotta believe me that i have seen the same questions in real exam that i had gone through them in mock exam.

There is one mock exam from wroxexam almost 250 questions, helped me a lot.\

You gotta give enough time for mock exams to score better.

Anyways, thanks for everyone help for my queries ;-).

regards,

Rafi

10 years ago

Suraj Jadhav wrote:Rafi, I have a contact number of NIIT Arora Tower Branch (Camp).

Contact Person: Sonali/Vineeta
020-30567017/19 or 020-30582439

May be this will help.



thanks yaar, i had to drop by and pay them there only.
i have paid 6,000 Rupees for SCWCD 1.5 .... the problem is that the day you go for exam, it can happen that the server is down or in the middle of the exam the system can hang ... than god bless you giving the exam all over again.

regards,

Frits Walraven wrote:Rafi,

Yes, you a right (and I just passed SCWCD ) the servlet is made as soon as you request it, but with direct access it doesn't load the init-parameters. The container only knows init parameters of a Servlet, not of a JSP, hence the need of a <servlet> and <servlet-mapping>

Regards,
Frits



Yeah, that is true. I accept the init-param parts.
Anyways, thanks for the help,

regards,

Rafi

Frits Walraven wrote:Ok, try this:

http://localhost:8080/JSPTest/OverridingJspInit.do

You have a servlet mapping from OverridingJspInit.do -> >/OverridingJspInit.jsp

What you are doing is going to the page via direct access (like accessing a static html page), so you are not creating a servlet.

Regards,
Frits



I can't believe it ... i had mapping and i was accessing it differently ... so that was the main reason in my point of view.

but i'm still confused about your statements:

1. Direct Access, like accessing a static html page [as i read in the book, the jsp files are supposed to be stored in webapp root directory and than accessed via http://localhost:8080/webapp-root/jspfile.jsp ....]
I had mapping for the <jsp-file> only because i was overriding jspInit() method, otherwise jsp pages doesn't need a mapping right, hence do you call that direct access???

check this code [same code, just one one expression added] :


check line number#12.

run this jsp file using : http://localhost:8080/JSPTest/OverridingJspInit.jsp
see the output, it will give you null values for the two parameters, but it executes the date perfect ... hence the servlet is created always when the request is made to the jsp page, right?

2. You are not creating servlet ...! how is that possible ... [as i read the moment jsp file is requested ... the container will create a servlet for that particular jsp file ..... even ]

why am i asking these questions are because i will be appearing for the exam soon, so if i could get some valuable information from your side, will definitely benefit me ;-).

thanks for the reply

regards,

Rafi

Frits Walraven wrote:Hi Rafi,

I just copied your code into my tomcat server(5.5) and it is woking well here, this is the output


Email Via ServletContext : r@gmail.com
Email Via ServletConfig : r@gmail.com

Above is example of overriding jspInit() method.


Are you getting the jsp at all on your screen?

Regards,
Frits



Tomcat Version: Apache Tomcat/5.5.28
File Name : OverridingJspInit [.jsp]
File Location: webapps root [webapps/JSPTest]{D:\tomcat\Tomcat 5.5\webapps\JSPTest\OverridingJspInit}
When I Run It In Browser : { http://localhost:8080/JSPTest/OverridingJspInit.jsp }
***do i have to set any path variable to this 'JSPTest'?****
The Output When I Run:

Email Via ServletContext: null
Email Via ServletConfig: null

Above is example of overriding jspInit() method.

**** only setting and retrieving of the context and init parameters doesn't work **** any guesses, copy of jsp and dd is above.

regards,

Rafi


Ankit Garg wrote:Is the name of your JSP file exactly OverridingJspInit.jsp??



Yes, that is the name exactly.
It access jsp file, it prints the line but values from initParameter and context parameter are = null.

regards,
hi guys,

I'm trying to override jspInit() and than set some context param from there, but doesn't work my way.
here are the code:

DD:


JSP code :


both the outputs from expression are "null" ???

regards,
Rafi
Hi guys,

I'm preparing for SCWCD 1.5 exams.
Have been trying to call NIIT prometric center, but no one responds.

How much is the costs for SCWCD 1.5 in Pune, India.

Any news when SCWCD 1.6 will be launched?

regards,

Rafi

Ankit Garg wrote:

Rafi Fareen wrote:1. there is two form purchaseGET.html & purchasePOST.html, both of them accessing same servlet
2. the servlet is performing some update in the database
3. if this servlet is invoked multiple times from either of the two html files, which one will have side effects and which one won't ?


Both will have side effects

Rafi Fareen wrote:4. which of the two methods are recommended by HTTP Specification?


For this case POST would be the recommended method to make a request to that servlet as it is making a side effect...



OK, Thanks alot.

Ankit Garg wrote:GET is inherently supposed to be idempotent i.e. generally get requests can be made multiple times without making any effects. If you submit a form using GET request and update the database, then multiple requests might make an effect. So in that case your GET request won't be idempotent. We should try to avoid such situations where a GET (or other idempotent HTTP methods) make an effect when multiple requests are made using them...



you said :

generally get requests can be made multiple times without making any effects.


and

f you submit a form using GET request and update the database, then multiple requests might make an effect. So in that case your GET request won't be idempotent.


we should try to avoid situations



if you explain this texts of yours using a real example, in the sense that:

1. there is two form purchaseGET.html & purchasePOST.html, both of them accessing same servlet
2. the servlet is performing some update in the database
3. if this servlet is invoked multiple times from either of the two html files, which one will have side effects and which one won't ?
4. which of the two methods are recommended by HTTP Specification?


reading one reply i feel that oh this idempotent stuff are just theory or lets say an advise and doesn't exists in real life, but reading other one i get confused saying it will have side effects or we should avoid using them.

If anyone can post one perfect example with a proper explanation {showing that ok, if we invoke this servlet with GET we have these advantages/disadvantages, effects/side effects, recommended/not recommenned, good programming behavior or not}, that example can always be used as a sample to everyone who is confused with the topic.

Searching through the forum, i found few threads on this topic, where everyone says different things.

Thanks for your replies everyone,

Regards,

Rafi


hi guys,

reading this book HFSJ, but i have not understood the explanation of Idempotent.

I have a form which uses GET request, i submit the form and in the servlet i use the form data to update a record in the database.
does that mean the record in database is not updated? if not such kind of update, than what exactly it means.

thanks

rafi

Rafi Fareen wrote:

Swagato Bhatta wrote:javac -classpath /apache-tomcat-6.0.18/apache-tomcat-6.0.18/lib/servlet-api.jar;classes;. -d classes src\com\example\web\SelectBeer.java

The first classpath tells where the servlet-api is located.
The second ones (probably) stating that "Please look inside the classes"
ALso . (probably) stands for "look in the current directory/folder too"

Please some correct me if I am wrong



javac -classpath classes -d classes src/com/example/web/SelectBeer.java [works fine.]

Thanks for the hint Swagato.




i have screwed up my brain by declaring the "classes" folder in the environment variable, but never worked from there ... i guess because of the relative/absolute stuff ... anyways i'm not good with packaging.

Swagato Bhatta wrote:javac -classpath /apache-tomcat-6.0.18/apache-tomcat-6.0.18/lib/servlet-api.jar;classes;. -d classes src\com\example\web\SelectBeer.java

The first classpath tells where the servlet-api is located.
The second ones (probably) stating that "Please look inside the classes"
ALso . (probably) stands for "look in the current directory/folder too"

Please some correct me if I am wrong



javac -classpath classes -d classes src/com/example/web/SelectBeer.java [works fine.]

Thanks for the hint Swagato.

Swagato Bhatta wrote:javac -classpath /apache-tomcat-6.0.18/apache-tomcat-6.0.18/lib/servlet-api.jar;classes;. -d classes src\com\example\web\SelectBeer.java

The first classpath tells where the servlet-api is located.
The second ones (probably) stating that "Please look inside the classes"
ALso . (probably) stands for "look in the current directory/folder too"

Please some correct me if I am wrong




i have the servlet-api.jar and jsp-api.jar in my classpath. i have mentioned that i can run the servlets, but here i'm facing little of package access problem, not servlet problem.
hi guys,

i'm reading this book named HFSJ and came across the first example.
having trouble with accessing packages.

my path is set to: D:\java\Development Area\Beer-v1

other java_home & tomcat_home paths are correct [because i have tested a servlet and its working].

there is a example that uses MVC architecture [beer example, of the same book].

so my development directory structure is:

D:\java\Development Area\Beer-v1\src\com\example\web\SelectBeer.java [servlet]

D:\java\Development Area\Beer-v1\src\com\example\model\GebBeers.java [plain java class]

as well the classes [have same structure as above, created while compilation with -d option]


my plain java code


my servlet code


i compile plain java file :

javac -d classes src/com/example/model/GetBeers.java [works, compiles and stores the .class file in classes directory structure]
but
javac -d classes src/com/example/web/SelectBeer.java [gives compilation error, while importing package model .... ]

i guess i'm missing something [maybe my classpath is not correct] or
maybe the import statement is looking into : src/com/example/model rather than looking in classes/com/example/model ......

any solution,

regards,

Rafi