{"id":290,"date":"2013-09-04T11:15:15","date_gmt":"2013-09-04T11:15:15","guid":{"rendered":"http:\/\/codethataint.com\/blog\/?p=290"},"modified":"2013-09-04T11:15:15","modified_gmt":"2013-09-04T11:15:15","slug":"servlet-using-setattribute","status":"publish","type":"post","link":"https:\/\/codethataint.com\/blog\/servlet-using-setattribute\/","title":{"rendered":"Servlet using setAttribute"},"content":{"rendered":"<p>Passing a Variable from Java to JSP Page By SetAttribute<\/p>\n<p><strong>Sample.java<\/strong><\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException \r\n{\r\n  request.setAttribute(&quot;Name&quot;, &quot;Mugil Vannan&quot;);\r\n  RequestDispatcher dispatcher = request.getServletContext().getRequestDispatcher(&quot;\/Sample.jsp&quot;);\r\n  dispatcher.forward(request, response);\r\n}\r\n<\/pre>\n<p><strong>Sample.jsp<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n  &lt;body&gt;\r\n    &lt;c:out value=&quot;${Name}&quot;\/&gt;\r\n  &lt;\/body&gt;\r\n<\/pre>\n<p><strong>Web.xml<\/strong><\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n  &lt;servlet&gt;\r\n     &lt;servlet-name&gt;Sample&lt;\/servlet-name&gt;\r\n     &lt;servlet-class&gt;com.sponsor.infonovum.MenuList&lt;\/servlet-class&gt;\r\n  &lt;\/servlet&gt;\r\n  &lt;servlet-mapping&gt;\r\n     &lt;servlet-name&gt;Sample&lt;\/servlet-name&gt;\r\n     &lt;url-pattern&gt;\/Sample\/&lt;\/url-pattern&gt;\r\n  &lt;\/servlet-mapping&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Passing a Variable from Java to JSP Page By SetAttribute Sample.java protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute(&quot;Name&quot;, &quot;Mugil Vannan&quot;); RequestDispatcher dispatcher = request.getServletContext().getRequestDispatcher(&quot;\/Sample.jsp&quot;); dispatcher.forward(request, response); } Sample.jsp &lt;body&gt; &lt;c:out value=&quot;${Name}&quot;\/&gt; &lt;\/body&gt; Web.xml &lt;servlet&gt; &lt;servlet-name&gt;Sample&lt;\/servlet-name&gt; &lt;servlet-class&gt;com.sponsor.infonovum.MenuList&lt;\/servlet-class&gt; &lt;\/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;Sample&lt;\/servlet-name&gt; &lt;url-pattern&gt;\/Sample\/&lt;\/url-pattern&gt; &lt;\/servlet-mapping&gt;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-290","post","type-post","status-publish","format-standard","hentry","category-servlets"],"_links":{"self":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/comments?post=290"}],"version-history":[{"count":1,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/290\/revisions"}],"predecessor-version":[{"id":291,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/posts\/290\/revisions\/291"}],"wp:attachment":[{"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/media?parent=290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/categories?post=290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codethataint.com\/blog\/wp-json\/wp\/v2\/tags?post=290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}