Anbarasu Aladiyan

Ranch Hand
+ Follow
since Jun 02, 2009
Anbarasu likes ...
Eclipse IDE Chrome Java
Merit badge: grant badges
For More
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 Anbarasu Aladiyan

Hi All,

While reading through “ Multithreading Issues” in “Java Servlet Specification V3.0” below statement is confusing me .

For servlets not implementing the SingleThreadModel interface, if the service method (or methods such as doGet or doPost which are dispatched to the service method of the HttpServlet abstract class) has been defined with the synchronized keyword, the servlet container cannot use the instance pool approach, but must serialize requests through it.

What does it mean by “Servlet Instance Pool”. As we know, there can be only one Servlet instance per declaration per JVM (in an non-distributed environment). Was “Thread Pool” misspelled as “Instance Pool” here? I believe Thread Pool also does not make any sense here. Tried search the web, but couldn’t get the relevant answers.

From struts2 doc
listKey -> used as key
listValue -> used as value
key -> Set the key (name, value, label) for this particular component
13 years ago
Have a look at this link. also please be aware of disadvantages of using this.
13 years ago
And Welcome to JavaRanch
13 years ago
[quote=June Rajkhowa]The problem is, to create the url I have to detect the event in the JSP page itself and not in the action class (which is the case at present).
I am not sure why you can't do that from action class. Since the action is different for different search types, you can do that easily. Without that this is not possible, coz when the request come back from the action, jsp does not knows about the parameters/fields were available in the previous JSPs (Assuming that search page and result page are different).

Or even you can set the EventType/SearchType from the action class, so that make the URL from JSP by depending on the 'EventType/SearchType' set from the action class. (Please note that again you need to do that from your action class)

Please let me know, if i miss something
13 years ago
no issues. you are welcome
13 years ago
You can set the url to be used in paging from the action class. Declare the Paging_Url_var and set the values accordingly from the action class. If it is for searchByEmployeeId and set it to “/searchByEmployeeId/someaction”, If it is for searchBySomethingElse and set it to “/searchBySomethingElse /someaction”. And you can user that variable in jsp page.
13 years ago
You have written DB connectivity code in JSP
13 years ago
For combobox, you can set the name, id attribute values as "someconstant"+id_from_db.
For checkbox, you can name as same for all checkboxes and set value attribute as id_from_dn. So you can get the selected checkbox in the "Array" form, which will have all the selected checkboxes values (ie.. ids_from_db).
13 years ago

Campbell Ritchie wrote:It is unnecessary to call flush() in that code. I trust you know why?

Thanks for pointing out . Calling close() will cause flush by default.
13 years ago
Oops... it looks like you are 'opening, writing, closing' the file in a loop. Whenever you write something to a file it does not appends the new lines/contents, it removes the existing file contents and adds the new contents. That's reason the last line is getting stored in the file.

I would suggest doing as below,

Read the contents from file1 and store it in ArrayList.
Open file2
Loop through the ArrayList and write it to file2
Close the file2

Also its good to flush the output
13 years ago
In common java objects, we will decide two objects are equal by checking its one or more than one instance variables.

Form javaDoc Comparator
return true -> only if the specified object is also a comparator and it imposes the same ordering as this comparator.
Means we need to check for its business logic (This is what really makes two comparators objects equal)

Also from JavaDoc
Note that it is always *safe not* to override Object.equals(Object).

Since the POJO class can have its own equals() which would check for some of its instance variables(Which makes it really unique). If we implement comparator interface in the same POJO class and provide the equals () for comparator then we cannot check equality for POJO class, vice versa. That is the reason it mentioned it's not to override equals().

As explained earlier this is to 'just to expand on the general contract of the method'. So that we would treat comparator equals() is different from POJO equals() .
13 years ago
and Welcome to javaranch
13 years ago
Below are some small snippets and behavior of compiler:
Above code causes compiler error because value of 'a' can be changed
Above cod compiles fine because if condition cannot be false
Above cod compiles fine because value of a cannot be changed (since a is final)
Above cod compiles fine because thePrice variable will be initialized to at least some value.

So compiler expects a constant (because it should not get changed by any other codes) to make sure conditions succeeds always.
13 years ago