Monday, December 31, 2012

HappyYear



Don't [Cubicles]  <http://www.smileycentral.com/?partner=ZSzeb001>  too hard but work smart.  May your boss appreciate you and say [Thumbs Up]    [Good Job]  <http://www.smileycentral.com/?partner=ZSzeb001> .
Take care of yourself [Dreaming]  <http://www.smileycentral.com/?partner=ZSzeb001> .    Pamper yourself and buy some beautiful [Shopping]  <http://www.smileycentral.com/?partner=ZSzeb001> [Wedding Dress]  <http://www.smileycentral.com/?partner=ZSzeb001> .
Don't worry coz   [Dollar]  <http://www.smileycentral.com/?partner=ZSzeb001>    will come from above.   May you also purchase  or change a [House]  <http://www.smileycentral.com/?partner=ZSzeb001>   and a [Car]  <http://www.smileycentral.com/?partner=ZSzeb001> . May the days ahead be busy but easy [Watching The Clock]  <http://www.smileycentral.com/?partner=ZSzeb001> ,     [Relax]  <http://www.smileycentral.com/?partner=ZSzeb001>   and  go [Cruising]  <http://www.smileycentral.com/?partner=ZSzeb001> [Pilot]  <http://www.smileycentral.com/?partner=ZSzeb001> around the world.   It's important to have good health,  therefore, eat more [Apple]  <http://www.smileycentral.com/?partner=ZSzeb001> [Broccoli]  <http://www.smileycentral.com/?partner=ZSzeb001> [Carrots]  <http://www.smileycentral.com/?partner=ZSzeb001>   and [Corn]  <http://www.smileycentral.com/?partner=ZSzeb001> , but not too much [Fat]  <http://www.smileycentral.com/?partner=ZSzeb001>   [Fat Guy]  <http://www.smileycentral.com/?partner=ZSzeb001> .   Do remember to [Tennis]  <http://www.smileycentral.com/?partner=ZSzeb001>  at least once a week.  My best wishes to you and all your [Family Portrait]  <http://www.smileycentral.com/?partner=ZSzeb001>   in the coming year 2013!

Sunday, November 18, 2012

basics of JSONP


what is it : It is JSON with some paddind
ex: JSON: {"name","sreenath"}
     JSONP: my({"name","sreenath"})
     in the above 'my ( )' is padding
Why[Usage]: To over come problem of same domain origin policy restriction of AJAX [ you cant make a AJAX call to different domain]. 

How it works:

Its all possible with one condition. < script > tag can access resources in different domain

1.You make request to cross domain resource using script tag passing call back function name.
    < script src="htt://mydomain.com/resource?callback=mycallbackfunc"/>
2. Make your server side code to return passed function with data.
     mycallbackfunc(JSON DATA) ex: mycallbackfunc({"name","sreenath"})
3. implement your call back funcion in your client side code
function   mycallbackfunc(data){
// write your logic here 
}

That is it you have done cross domain request.


Limitations:
1. You can not make POST request with this
2. server side code needs to be written to return JSONP data






Friday, June 25, 2010

Tracking cookies

What is it
Cookies used for tracking your browsing habits.
How they work:

I have a website say http://www.domain1.com/ and have some advertiser ads placed in it. When I access the wesite I will be making a request to advertiser to get the ads. Advertises knows that the request is coming from a partner site domain1.com . That time advertiser places a cookie. stores this website URL and associate it with cookie.

Now I visit one more site say http://www.domain2.com/ which also has the same advertiser ads. When I access this website I will be making the request to advertiser. but this time browser will send the cookie set in the previous request.Now advertiser gets the cookie and checks the stored previously based on that delivers the content and adds this URL also to the visited sites.

Why?
Will be used by advertising companies to advertise based on your browsing habits.


Is it harmful?
No.

Can I block them?
Yes. check your browser settings.

Thursday, June 24, 2010

javax.servlet.forward AND javax.servlet.include

from servlet spec

requestURI = contextPath + servletPath + pathInfo

Include

When you include a servlet the following attributes will be set by the calling servlet
the attributes will be derived from the string you passed to include the servlet

javax.servlet.include.request_uri
javax.servlet.include.context_path
javax.servlet.include.servlet_path
javax.servlet.include.path_info
javax.servlet.include.query_string

ex:
first.jsp code
=========
rd = request.getRequestDispatcher("/myapp/second.jsp?pname=pvalue");
rd.include(request,response);
assume the context for your webapp is "myapp"

javax.servlet.include.request_uri : /myapp/second.jsp
javax.servlet.include.context_path : /myapp
javax.servlet.include.servlet_path : /second.jsp
javax.servlet.include.path_info : null
javax.servlet.include.query_string : pname=pvalue


Forward

when you forward to a servlet the following attributes will be set by calling servlet

javax.servlet.forward.request_uri = request.getRequestURI() value in the calling servlet
javax.servlet.forward.context_path = request.getContextpath() value in the calling servlet
javax.servlet.forward.servlet_path = request.getServletpath() value in the calling servlet
javax.servlet.forward.path_info = request.getPathInfo() value in the calling servlet
javax.servlet.forward.query_string = request.getQueryString() value in the calling servlet

ex:
first.jsp code
=========
rd = request.getRequestDispatcher("/myapp/second.jsp?pname=pvalue");
rd.forward(request,response);
assume the context for your webapp is "myapp"

Access URL is: http://localhost:8080/myapp/first.jsp?first=first

javax.servlet.forward.request_uri : /myapp/first.jsp
javax.servlet.forward.context_path : /myapp
javax.servlet.forward.servlet_path : /first.jsp
javax.servlet.forward.path_info : null
javax.servlet.forward.query_string : first=first


Is path_info is null always?

No.
This will come into picture when your servlet is matched by /* pattern in web.xml

ex:
your appication context is myapp and have 1 entries in web.xml for  a servlet with following mapping

Servlet Mapping Pattern: /lawn/*

and the request from client is

http://localhost:8080/myapp/lawn/grretings/d.html

here path info : /greetings/d.html
Servlet path   : /lawn

Friday, June 18, 2010

SelfSigned certificate creation in java

Keytool file will be shipped with JDK

1. Goto %JAVA_HOME/bin
2. Run the following command

keytool -genkey -keypass mykeypass-keystore d:\apps\myproj\cacerts -storepass mystorepassword -keyalg rsa-alias sreddy
Here
keypass : Your public/private key pair will be protected with this password
KeyStoreFilename : path to the keyStore file (default: JAVAHOME%\lib\security\cacerts)
storepass : password for the key store (default: changeit)
alias : this unique name will be used to identify the certificate. U can delete or modify with this name later
keyalg : Algorithm to be used. Use rsa







Thursday, June 17, 2010

Trust vs Identity keystore in weblogic

Identity keystore:

This will be used to store the server certificate(private key/digital certificate pairs). When the client contacts server the digital certificate presented in this keystore will be sent.

Trust Keystore:

This will contain the certificates whom weblogic trust( ie root CA certificates like VeriSign,GoDaddy etc).When a client presents their certificate it checks the issuer of the certificate. If it is issued by CA whose certificate is in the trust store then the validation passes. otherwise weblogic detects it as an invalid certificate.

more details

http://one-size-doesnt-fit-all.blogspot.com/2009/09/weblogic-server-identity-vs-trust.html