Abhishek Purwar

Ranch Hand
+ Follow
since Dec 15, 2007
Abhishek likes ...
Eclipse IDE Spring Java
Merit badge: grant badges
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 Abhishek Purwar

Hi All,

Need some information for thread dump analysis. What does below statement signifies and what could be possible reason for this log?

Owns Monitor Lock on com/ibm/ws/util/BoundedBuffer$GetQueueLock@0x000000060295C5F8/0x000000060295C604

This locks own by WebContainer thread.

Application uses Websphere ApplicationServer, Websphere MQ and DB2 database.

Please help me in understanding what could be possible cause for this log.
Hi,

I have query for thread synchronization.

Suppose there are three threads and there is one method which takes number as input and prints number.
If threads passes same number, number should print one time and if different numbers provided as input then all different number should print.

For e.g.
If thread1 and thread2 passes 1 as input to method and thread 3 passes 2 as input then 1 should print once and 2 should print once.
If thread 1 passes 1, thread 2 passes 2 and thread 3 passes 3 then all number should get printed as all are different.

Please suggest me how I shall achieve this.

Regards,
Abhishek
Thanks Manjesh for information.
Can you provide some code example?
12 years ago
Hi All,

I want to know about CSRF(Cross Sit Request Frogery) attack and what are various solutions using which i can prevent this attack.
Also provide views on which is the best solution which I can implement and how should I test my site for this attack and other breaches.

Thanks in advance for providing suggestions.
12 years ago

Ashish Malik wrote:I have used the addition of 'user object' in the session so no problems there.
Also i tried to set these headers in response from where the jsp page is spit out. No use.



Did your issue got fixed with mentioned changes or not??
12 years ago
@Tejas: Filter is suitable if one wants to modify/filter request based on some conditions. Servlet is useful when you want to control, preprocess and/or postprocess requests.

Filter is useful for following scenarios :
1)Query the request and act accordingly.
2)Block the request-and-response pair from passing any further.
3)Modify the request headers and data. You do this by providing a customized version of the request.
4)Modify the response headers and data. You do this by providing a customized version of the response.
5)Interact with external resources.

And for more information about filter, check following link : http://www.oracle.com/technetwork/java/filters-137243.html

And one more thing, every component is defined for certain purpose and we cannot mix purpose of two component. In java, servlet is base for everything in JEE and one can do whatever one wants using servlet.
12 years ago
Create one servlet and for every request, set response header with this.
12 years ago
Url mapping is the path which is associated with servlet if you want to access servlet using http request.
In web.xml file, one can define url mapping for different servlets.

Can you provide sample urls which you want to invoke from different links??
12 years ago
@Ravishanker : My issue is related to content-type of response header and not an accessing issue. I have fixed my issue and it is working fine now.

Thanks for your response.
12 years ago
You cannot call servlet methods directly from html page. onClick attribute works for javascript functions and not for servlet methods.
For servlet methods, you need to create url mapping and call url for servlet from HTML page.
12 years ago
After logout, you can set following values in response header and it will work.

HttpServletResponse httpResponse = (HttpServletResponse) res;
httpResponse .setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
httpResponse .setHeader("Pragma", "no-cache"); // HTTP 1.0.
httpResponse .setDateHeader("Expires", 0); // Proxies.

Try this and let me know your feedback.
12 years ago
Thanks for your responses.

@Sujata : I need to set content type for all static resources at common place and not in some class file.

@Rob: Actually, mime-mapping I setup at wrong place in web.xml file. Now I place it just befoe welcome-file-list tag and it is working now.

Issue is resolved.
12 years ago
Filter mapping issue is fixed and now filter is getting called for every request.

Any suggestion for content type issue??
12 years ago
Thanks for your reply Rob.

Following are the filter mapping which I set up:

<filter>
<filter-name>{filter name 1}</filter-name>
<filter-class>{Class name}</filter-class>
</filter>
<filter-mapping>
<filter-name>{filter name 1}</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>{filter name 2}</filter-name>
<filter-class>{Class name}</filter-class>
</filter>
<filter-mapping>
<filter-name>{filter name 2}</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

For static resource, none of this get called.

And I set the mime-mapping in web.xml but nothing happens. (.png file get parsed by browser and shows character stream in browser instead of image, .ico file same as .png and for some other types of file also.) Following is mime-mapping which I setup in web.xml file :

<mime-mapping>
<extension>png</extension>
<mime-type>image/x-png</mime-type>
</mime-mapping>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>

And I am using weblogic server for my application and environment is linux.

Please provide some suggestion for this.
12 years ago
Filter is used for filtering the request and perform some action like authenticity of session, user is valid or not for that request, etc.
Servlet is used for performing the action which needs to be taken for particular request like user login, get the response based on user role, interacts with database for getting the data, business logic execution, etc.

Filter has different purpose and servlet has different purpose.
12 years ago