Kala Saseendran

Greenhorn
+ Follow
since May 24, 2012
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Kala Saseendran

I am pretty new to MongoDb. However i am trying to implement below functionality using java.

I Have a document as below. 

{
    "_id" : ObjectId("like-001"),
    "GroupID" : "1004",
    "likedBy" : [ 
        {
            "personId" : 123,
            "liked" : true
        },
 {
            "personId" : 167,
            "liked" : true
        },
 {
            "personId" : 467,
            "liked" : false
        }
    ],
    isdeleted:false
}



My functionality is, given a groupid, personId and Liked , find whether any document exist with given GroupId. If exist i should update that document with personId and Liked if the record not present, if person id also present I should not add the same person in array.

If the group id itself is not present I have to insert the entire document.

is there a way to do this with out making multiple calls to database. Also can this be done in bulk?



1 year ago
I have implemented basic auth using security constraint via WEB.xml for my web application as below. It is working as expected. However when i press cancel button in the window which asks for username and password, It keeps on askinhg for more than 8 times and then only showing the error screen. Is there a way to configure the retry count for incorrect credentials and cancel button.
2 years ago
Thanks for the suggestion.
2 years ago
I have a class that will run configured number of threads, to read form a BlockingQueue. the threads count will be initialised on load of the class and those many threads will be running at a time.
My threads will be coming back to thread pool only when the server is stopped, as the threads will be waiting on the blocking queue for new data.
At some point of time i would like to dynamically change the thread count. Is there a way to do that. My sample code looks as below.

The variable workerThreads is initially assigned to 2.
Inside the run method i would like to read this variable again form some config and get the value.
Then as per that value i would like to increase or decrease the number of QueueProcessor threads running at a time.
Please let me know any one have worked in similar scenarios and the best feasible solution that can be provided.

2 years ago
As below i m creating cookie .



I am trying to read that cookie in javascript as below.

var cookieValue = $.cookie("myck");

I can see the cookie in the browser. However the read is not happening I tried to set httponly to false



However it is throwing compilation error as my servlet version is 2.5

Is there any way to get the cookie in javascript?
2 years ago
Thanks all for the information shared.
3 years ago
I am learning few concepts in servlets. And i came across this doubt. We used to send data over network using httpsession as below.



And get the data in JSP with below code


How ever i am not sure whether HTTPSession is serializable or not.

Can some one explain how HTTPSession works?



3 years ago
I have went through simpledateformat. that is how i come up with the existing date pattern. I have change dthe pattern as belwo



and this is giving me dat as below

2014-07-17 05:46:05 GMT+00:00

How ever as the offset is +00:00 i dont want it to be printed and the output should be as below

2014-07-17 05:46:05 GMT


I tried various patterns. None of them are working.


Thanks
Kala
I have configured my log4j as below.

and in log i am getting date as below

2014-07-16 07:13:07,470

I need the date format as below.
2014-07-16 07:13:07 GMT

Can any one please let me know what modification should i do?

Thanks
Kala


above piece of code is sent to review and returned back saying there is a security issue. Please find the issue details below

XML parser configured in (transformer.transform(xmlSource, new StreamResult(out));) does not prevent nor limit external entities resolution. This can expose the parser to an XML External Entities attack.using xml parsers configured to not prevent nor limit external entities resolution can expose the parser to an xml external entities attack.

Can any one please help me to fix the same?
3 years ago
I am trying to work understand Response wrapper. I am able to find a simple example which is working fine. And it is as below




I see here the response is not really modified instead after dofilter we added some content with response string and printed it on browser. My question is like Can we modify the response content using filter, as we do for request header and parameter. If so how can i do that?
3 years ago
Added Javascript to validate the fields. that solved the issue.
3 years ago
I am trying to rewrite the filereading functionality with bounded buffer reader My initial code was as below


Code:


New Code:


I understand that the BoundedInputStream that wraps the given input stream and limits it to a certain size(the size is mentioned in the constructor called). My question is that as i am using line reader the limit is for each line or for the entire content?
3 years ago
The value of pType come from a servlet. And i need that value in the servlet which is called after this JSP. It is a scriptlet. It worked without double quotes

Thanks
Kala
3 years ago