Saturday 21 May 2016

scope of public,private,protected in java for class method

public : method which are public there scope is available to child and which ever class wants to use it.
protected : scope visible only in child package
private :  scope visible only in class. 

Difference between pathparam and QueryParam in Rest.

Difference between pathparam and QueryParam in Rest.

Pathparam : used get the part of the string from URL.
ex:  @Pathparam("id")
ex : http://localhost:8080/voice{id}

QueryParam  : using this we are able to access the key,value after from URL after "?"
ex:  @QueryParam("id")
ex : http://localhost:8080/voice?id=1009

Log file in tomcat.


1) catalina.log -- logs all the  log at the time of server start
2) localhost_access_log : logs all the request type and URI
ex :
a) 0:0:0:0:0:0:0:1 - - [21/May/2016:11:21:52 +0530] "GET /voice/p1x/network HTTP/1.1" 200 -
3) server.log : logs "ContainerBackgroundProcessor" info and error stack.
4) error.log : logs all the error stack
5) hostmamager.log :
6) manager.log : logs info about HTMLManager,manager,
ex : INFO: HTMLManager: init: Associated with Deployer 'Catalina:type=Deployer,host=localhost'
ex : INFO: HTMLManager: init: Global resources are available
ex : INFO: HTMLManager: list: Listing contexts for virtual host 'localhost'

Friday 20 May 2016

what is purpose of calling chain.doFilter() in servlet


what is purpose of calling chain.doFilter() in servlet
chain.doFilter(request, response);

The name chain suggests that you have a sequence of filters, with each filter doing some processing and then passing on to the next in sequence, so each object has a chain member to point to the next filter in the sequence, which gets called after the filter has performed its own processing. The last in the sequence will then probably have null as the chain value, or it knows on its own that it is the last one in the sequence.

Ref : stackoverflow
author JK

public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
...

chain.doFilter(request, response);
}

after executing the method  on calling chain.doFilter() it will call filter present in web.xml in the order of defination.


<filter>
  <filter-name>VoiceLoginFilter</filter-name>
  <filter-class>com.voice.filters.VoiceLoginFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>VoiceLoginFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

when to use boolean and Boolean in java

when to use boolean and Boolean
1. if you want to have true or false use boolean.
2. if you want to have true or false or Null use boolean.

Ref : stackoverflow

Thursday 19 May 2016

When to use detached criteria and criteria.

When to use detached criteria and criteria.

detached criteria : if we want to create a query wihout any session
Ref : Stackoverflow

another alternative is

If you are using Spring and choose to use HibernateTemplate, it doesn't provide createCriteria() method.

Ref :  spring

Generic Maps in Collections


Generic Maps in Collections
IF we want to restrict the type of object we can go for Generic Map using Map<key,value> pair

Map<String, Object> map = new HashMap<String, Object>();
In the above example the map object will accept key of type string and value of type Object