{"id":2606,"date":"2017-09-02T07:01:50","date_gmt":"2017-09-02T07:01:50","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2606"},"modified":"2017-09-02T07:01:50","modified_gmt":"2017-09-02T07:01:50","slug":"how-to-use-application-object-in-jsp-page","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-use-application-object-in-jsp-page\/","title":{"rendered":"How to use Application object in JSP page"},"content":{"rendered":"<p>In this tutorial how to use Application object in JSP page \u00a0is shown.<\/p>\n<p>Steps to directly launch a different default page on the browser instead of index.html page:<\/p>\n<ul>\n<li>Right click on Web Pages folder<\/li>\n<li>Select the Properties option<\/li>\n<li>Open the Run tab<\/li>\n<li>In Relative URL textbox write the name of the page you want as your default page.<\/li>\n<li>\u00a0Then click on OK<\/li>\n<\/ul>\n<p>Code:<\/p>\n<p>Counter.jsp<\/p>\n<p>&lt;%@page contentType=&#8221;text\/html&#8221; pageEncoding=&#8221;UTF-8&#8243;%&gt;<br \/>\n&lt;%@page import=&#8221;java.io.*,java.util.*;&#8221; %&gt;<br \/>\n&lt;!DOCTYPE html&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=UTF-8&#8243;&gt;<br \/>\n&lt;title&gt;Count Page&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n&lt;%! Integer counter; %&gt;<br \/>\n&lt;%<br \/>\ncounter=(Integer)application.getAttribute(&#8220;numberOfVisits&#8221;);<br \/>\nif(counter==null|| counter==0)<br \/>\n{<br \/>\ncounter=1;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ncounter=counter+1;<br \/>\n}<br \/>\napplication.setAttribute(&#8220;numberOfVisits&#8221;,counter);%&gt;<br \/>\n&lt;h3&gt;Total number of hits to this Page is: &lt;%=counter%&gt;&lt;\/h3&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/youtu.be\/zaz-EQP4Ruo\">https:\/\/youtu.be\/zaz-EQP4Ruo<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to use Application object in JSP page \u00a0is shown. Steps to directly launch a different default page on the browser instead of index.html page: Right click on Web Pages folder Select the Properties option Open the Run tab In Relative URL textbox write the name of the page you want as your default page. \u00a0Then click on OK Code: Counter.jsp &lt;%@page contentType=&#8221;text\/html&#8221; pageEncoding=&#8221;UTF-8&#8243;%&gt; &lt;%@page import=&#8221;java.io.*,java.util.*;&#8221; %&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=UTF-8&#8243;&gt; &lt;title&gt;Count Page&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt; &lt;%! Integer counter; %&gt; &lt;% counter=(Integer)application.getAttribute(&#8220;numberOfVisits&#8221;); if(counter==null|| counter==0) { counter=1; } else { counter=counter+1; } application.setAttribute(&#8220;numberOfVisits&#8221;,counter);%&gt; &lt;h3&gt;Total number of hits to this Page is: &lt;%=counter%&gt;&lt;\/h3&gt; &lt;\/body&gt; &lt;\/html&gt; &nbsp;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[123],"tags":[125,147,124,145],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2606"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2606"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2606\/revisions"}],"predecessor-version":[{"id":2608,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2606\/revisions\/2608"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2606"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}