ankit maini

Greenhorn
+ Follow
since Feb 08, 2011
ankit likes ...
Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by ankit maini

I have read about vector that it is synchronized means its methods are synchronized, In the give below example i am adding elements in a vector by three threads, I am confused why its behavior is not synchronized .



Output is:
Thread-3
Thread-5
Thread-1
Thread-5
Thread-1
Thread-3
Thread-5
Thread-3
Thread-1
Thread-5
Thread-3
Thread-1
Thread-5
Thread-3
Thread-1
15
element0
element0
element0
element1
element1
element1
element2
element2
element2
element3
element3
element3
element4
element4
element4

Here if vector's add() method is synchronized then result should be
element 0
element 1
element 2 ... and so on

I am confused ???
11 years ago

naveen yadav wrote:Now it gets clear that object get GCed not reference var. There are 2 object created ob and obj .

obj is eligible foe GC. since obj is nul in line 10l.

what about ob ?
Will this make ob object also eligible for GC ? since ob was referring to the obj object in line 9.


I think ob is also eleigible for GC ?? anybody agree.







First of all, objects are garbage collected not reference variable. In this case there are 3 reference variables and 2 objects are created.
one is refer by ob and second is refer by obj.Now at line 9 the object which is referred by obj is also refer by ob and the object which is referred by ob is redy for GC(because one ref variable can only refer to one object at a time but one object referred by multiple ref variables at a time).
At line 10 obj=null does not mean that another object is also garbage collected because ob is referred at line 9.
At line 11 the object referred by ob is also referred by ref.

BUT all reference variables are local variables so at line 14 all objects are ready for GC so answer is 2.
# String str = new String("scjp"); // in this case new string object create and str refer this object.
# str = new String("ocjp"); // in this case new object create and now str refer to this object so previous object is ready fo gc.
I think answer would be 1
because b1 is actually Static reference variable in class Alpha. So even if we do a1=null still the object exist and we can access by Alpha.b1. So only one object is garbage collected which is referred by a1.
Correct me is if i am wrong.

Regards
Ankit Maini
Hi All...


Struts1- After submitting username and password, if it is incorrect i want to print a message that "your username or password is incorrect" in a login page itself.

Note: I don't want to use scriplets.
Is there any other alternative(with struts tag)??

My control flows like this...

login page -> Action Form -> Action (Here i am checking userName and Password) (If wrong then redirect to login page with a message )

I can't use <bean:write> tag because at first time My ActionForm object has not created.

Please give me the Solution.


Regards
Ankit Maini
12 years ago

Rob Spoor wrote:Which browser are you using? Accessing the clipboard is blocked by some browsers; Opera for instance (my browser) doesn't support it at all. This is done because of security, to prevent malicious sites to copy and/or paste to/from the clipboard.




I am using Firefox 4.0.1
12 years ago
copy to clipboard is not working Please check .
Thanks
12 years ago
@rohit chavan

Thanks
12 years ago
Please reply as soon as possible.
12 years ago
I am using struts 1.1.
In my project i have one message-resources file called ApplicationResource.properties . Now i want to get the value of a key say my database password and username from this properties file in normal java class in my project. How can i do this. Please explain.

Thanks in Advance
12 years ago
How to apply the security in web.xml could you please specify .
12 years ago
Hello

I am making a small project in jsp and servlet. There are three users visitor member and admin in my website. Admin Upload the PDF File into to folders
1st in myWebApp\pdf\member for Members
2nd in myWebApp\pdf\visitor for visitor

Now I want visitor to restrict to view or download the member's pdf.

How can I do this ?
Is it possible with filters if yes then how??
Is there any another way ??
12 years ago
I m making a Notepad in java. I want to provide a functionality of compile and run the java program written in JTextArea. I have search about Runtime Class but i m not getting it properly.So can you please guide me how to compile the code and run the program.
13 years ago
hi
I have one tabbed Pane and 4 tabs say tab1,tab2,tab3 and tab4.
In these tabs scroll pane is there and each scroll pane has text areas. Now i want to get the text from current text area how to reach at current selected JTextArea ?
13 years ago



According to the Operator Precedence < has higher precedence than || so it should solve first and output should be 4. but the answer is 3 WHY?
13 years ago