Help coderanch get a
new server
by contributing to the fundraiser

akaash singh

Ranch Hand
+ Follow
since Jul 04, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by akaash singh

I need to understand the behaviour of the following :



This works if i use the sample :


But the css does not work in this case :


Why is this so ? What I understand is thatthe css should apply to every element which has both m and y classes and is nested in class d.

Please help
Akash Singh

akaash singh wrote:
Why is it so ? Shouldn't I be able to add two servlets with the same name as long as I put them in different packages ?


Why would you need to have Servlets with the same name? Servlets are used as controllers for processing your requests.

Suppose I create two servlets with the same name in different packages and the actual package to be used depends on some condition . I know this isn't a very good example but cooked it up just for the sake of an example .
But that's that's whole purpose of packages that two packages can have classes of same name as without conflict. And of course its possible if we don't use an IDE. Is this a eclipse specific thing ?
Hi

I using eclipse . I created a Dynamic Web project . I put the servlets inside packages in the source folder and the html and JSPs in the web content folder. I am not able to add two servlets with the same name inside different packages . A prompt is thrown saying that a servlet with name already exists ?

Why is it so ? Shouldn't I be able to add two servlets with the same name as long as I put them in different packages ?

Also suppose I create a servlet "servA" iniside a package named "p1" . I have to specify the servA in the action attribute of some jsp . How do i specify it ?

- as action ="p1.servA" (this did not work)
or
- simply as : action="servA" ( this worked)

Why is it so ? Isn't the first way correct ?

Are these issues related to eclipse ?

Thanks and Regards
Akash
Hi ,
I think it will only be clear once I deploy the application . However I have the following doubts :-
- When does a browser discard a session ?
-Correct me if I am wrong : Server discards a session in case of calling invalidate and logout or when the MaxInactiveInterval lapses.
If we do not specify a value for this by calling the setMaxInactiveInterval , what is the default value of this interval ?
13 years ago
Thanks William

So is it that the client i.e. the browser provided by eclispe maintains cookies as long as eclipse is running , irrespective of whether the server has been stopped ?

If I were to run it manually , (that is to say copy the application into web-apps , start tomcat manually and use a proper browser) would the session persist on restarting the server ?

I am yet to learn deploying applications , so haven't tried this out.

13 years ago
Hi ,

I am a beginner in servlets . I am studying it from Core Servlets and JSP . I am using eclipse with tomcat plugin(sysdeo) and the browser built in eclipse for practice purpose .

I tried the ShowItems + OrderForm example given in the chapter 9(Session Tracking) . http://volume1.coreservlets.com/archive/Chapter9.html

In this a HttpSession object is created and arraylist object is added to it. This arraylist stores the items ordered . Each time the user orders an item it is stored in the object . No method except for getAttribute and setAttribute is called on the session object

The example works fine .

But once I stop the server and restart it(from within eclipse) and run the example(without closing eclipse) , the session persists. However if i stop the server and then restart eclipse and then run the example , the session is deleted and a new session is created .

Why is it so ? Shouldn't the session be destroyed on restarting the server . And if no , the why does it gets destroyed on restarting eclipse ?

Thanks and Regards
Akash
13 years ago
Hello Bear

It was just a dummy servlet to check whether everything's configured right . I compiled it in a different directory and just placed the .class file in install_dir/webapps/ROOT/WEB-INF/classes. There were no packages involved .
13 years ago
Hello ,

I have just started learning servlet and jsp . I am using tomcat version 5.5.31 , jdk 1.6 and vista . I configured tomcat according to the tutorial on http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-5.5.html.

After compiling a very basic servlet example I placed the class file in install_dir/webapps/ROOT/WEB-INF/classes as prescribed in the tutorial.
But the servlet did not run.
After that i placed it in install_dir/shared/classes and it ran .

But surprisingly when I ran other servlet examples they did not run from install_dir/shared/classes but from install_dir/webapps/ROOT/WEB-INF/classes. And i am totally confused . I had followed every step carefully . Please explain this result. Why did i have to change directory after the first servlet execution ?

Thanks and Regards
Akash Singh
13 years ago
Hi everyone ,
cleared my scjp on 14th august . thanks to all fellow ranchers and specially to :
deepak bala
Jason irwin
Henry Wong
Ankit Garg
Mo jay
Himanshu kansal
AAkash goel
Nitish Bangera
Shviendra Tripathi
Ken Truitt

for taking the trouble to answer my queries.
Sorry if missed anyone .

Regards
Akash Singh
15 years ago
i understand that we can synchronize by making the following change :

public synchronized void run() {//}

but what does "this" refer to : is it the object "r" of class Run ?
or is it the object of class T1.
The 2 threads must have access to the same object in order to cause synchronization problems. What is that same object here: "r" or the "anonymous object of class T1"
Synchronization problems occur when two threads have a access to the same object . In the following code :



In this we have two threads t1 and t2 . The common object they share is "r" . " r" has access to x ; thereby granting t1 and t2 access to x , leading to synchronization problems in the output .

i have the following doubts :
- is the above reasoning correct ?
- the objetc on which run() is executed is "r" and not t1 and t2?

And when we extend the Thread class the run() is executed on the object of the subclass of Thread ? as in :



So here the run() is executed on ob?

ya dat last thing too. Was thinking that i had missed it . neways thanks a lot mate.
so were all the three statements correct ? please reply . i need to hear it , it'll be a boost to my dwindling confidence level