Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760
Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760
Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /home2/learnera/public_html/tech/wp-includes/comment-template.php on line 1747
Deprecated: Creation of dynamic property WPtouchProFour::$settings_object is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/class-wptouch-pro.php on line 82
Deprecated: Automatic conversion of false to array is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/admin-load.php on line 70
Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block-type.php on line 391
Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block-type.php on line 391
Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347
Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349
Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350
Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351
Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354
Deprecated: Creation of dynamic property YARPP::$is_custom_template is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 56
Deprecated: Creation of dynamic property YARPP::$db_options is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 69
Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118
Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 63
Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 73
Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 89
Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 102
Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 111
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82
Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_author is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_date is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_date_gmt is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_content is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_title is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_excerpt is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$comment_status is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$ping_status is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_password is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_name is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$to_ping is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$pinged is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_modified is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_modified_gmt is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_content_filtered is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_parent is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$guid is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$menu_order is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$post_mime_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$comment_count is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$filter is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$author_name is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$author_profile_url is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$avatar_url is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$avatar is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$thumb is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$preview is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$file_count is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$page_url is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$page_link is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$page_url_qr is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$btnclass is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$file_size is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$file_type_icon is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$download_url is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$download_link is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$download_link_extended is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$download_link_popup is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$formatted is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$__template is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Deprecated: Creation of dynamic property WPDM\Package\Package::$__template_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/download-manager/src/Package/PackageController.php on line 375
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/rest-api/class-wp-rest-server.php on line 1723
{"id":108,"date":"2014-05-09T06:15:40","date_gmt":"2014-05-09T06:15:40","guid":{"rendered":"http:\/\/tech.learnerandtutor.com\/?p=108"},"modified":"2018-04-17T15:43:45","modified_gmt":"2018-04-17T15:43:45","slug":"send-json-object-to-struts-2-action-by-jquery-ajax","status":"publish","type":"post","link":"http:\/\/tech.learnerandtutor.com\/send-json-object-to-struts-2-action-by-jquery-ajax\/","title":{"rendered":"Send JSON object to Struts 2 Action by JQuery AJAX"},"content":{"rendered":"To send data from client side to server side, one of the best way is send as JSON object.
\nPlease follow the steps below to achive this.<\/p>\n
To do this first we have to enable json compatibility in the struts2 framework. For this modify the struts.xml file as below.<\/p>\n
<interceptors>\r\n <interceptor-stack name=\"defaultStack\">\r\n <interceptor-ref name=\"json\">\r\n <param name=\"enableSMD\">true<\/param>\r\n <\/interceptor-ref>\r\n <\/interceptor-stack>\r\n<\/interceptors><\/pre>\nIn the above code we added the json interceptor to the defaultStack. If you have your own stack add the lines below to your stack.<\/p>\n
<interceptor-ref name=\"json\">\r\n <param name=\"enableSMD\">true<\/param>\r\n<\/interceptor-ref><\/pre>\nNext extend the json package to the default package as below<\/p>\n
<package name=\"default\" namespace=\"\/\" extends=\"json-default\"><\/pre>\nAnd the last change in the struts.xml file is set the return type as json for the request action.<\/p>\n
<action name=\"writeJSON\" class=\"com.rajesh.json.ReadJSON\" method=\"writeJSON\">\r\n <result type=\"json\" \/>\r\n<\/action><\/pre>\nThat’s all the change for struts2.xml<\/p>\n
In our example we are going to send data from the client side to server side. So we will create a json data object with javascript as below.<\/p>\n
var dataObj = {\r\n \"data\": [{\r\n \"active\": \"true\",\r\n \"color\": \"orange\",\r\n \"date\": \"2008-01-01\",\r\n \"id\": \"1\",\r\n \"name\": \"Chris\"\r\n }, {\r\n \"active\": \"false\",\r\n \"color\": \"blue\",\r\n \"date\": \"2013-03-03\",\r\n \"id\": \"2\",\r\n \"name\": \"Kate\"\r\n }, {\r\n \"active\": \"true\",\r\n \"color\": \"black\",\r\n \"date\": \"2013-05-03\",\r\n \"id\": \"3\",\r\n \"name\": \"Blade\"\r\n }, {\r\n \"active\": \"false\",\r\n \"color\": \"yellow\",\r\n \"date\": \"2013-01-01\",\r\n \"id\": \"4\",\r\n \"name\": \"Zack\"\r\n }]\r\n};<\/pre>\nThe JSON object syntax will be<\/p>\n
{\"varName\":\"value as String\"}<\/pre>\nIn the above code, we created a variable dataObj which has only one variable data. But the variable “data” contains 4 objects. Each object\u00a0has four variables namely “active”,”color”,”date”, “id” and “name”.<\/p>\n
Now we will see how this is getting called in detail. First convert the created object into json object with the below code.<\/p>\n
var data1 = JSON.stringify(dataObj);<\/pre>\nThis line of code will convert the object to json string. If you want to know the difference before and after in detail display it in the console\u00a0and view in the browser console window like below.<\/p>\n
console.log(dataObj); console.log(data1);<\/pre>\nThen to send this data to the action write the javascript code below.<\/p>\n
$.ajax({\r\n url: \"writeJSON.action\",\r\n data: data1,\r\n dataType: 'json',\r\n contentType: 'application\/json',\r\n type: 'POST',\r\n async: true,\r\n success: function (res) {\r\n console.log(res.data.length);\r\n for (var i = 0; i < res.data.length; i++) {\r\n console.log(\" \" + res.data[i].name + \"-\" + res.data[i].id + \"-\" + res.data[i].active + \"- \" + res.data[i].date);\r\n }\r\n }\r\n});<\/pre>\nWhen we execute the above code, the struts framework will look the data object then it will find a variable with name “data”. So it will look\u00a0for the method setData() method in the action class ReadJSON.java. If it is there it will run the code and try to parse the data.<\/p>\n
See the action class ReadJSON.java below.<\/p>\n
package com.rajesh.json;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\nimport com.rajesh.json.Report;\r\nimport com.opensymphony.xwork2.ActionSupport;\r\npublic class ReadJSON extends ActionSupport {\r\n private static final long serialVersionUID = -6765991741441442190L;\r\n private List < Report > data;\r\n public String writeJSON() {\r\n try {\r\n System.out.println(data.size());\r\n for (int i = 0; i < data.size(); i++) {\r\n System.out.println(\"Data \" + data.get(i).getColor() + \"-\" + data.get(i).getDate() + \"-\" + data.get(i).getId() + \"-\" + data.get(i).getName());\r\n }\r\n System.out.println(\"Execute Method\");\r\n } catch (Exception e) {\r\n e.printStackTrace();\r\n }\r\n return SUCCESS;\r\n }\r\n public List < Report > getData() {\r\n System.out.println(\"Getter Call\");\r\n return data;\r\n }\r\n public void setData(List < Report > data) {\r\n System.out.println(\"Setter Call Flow\");\r\n this.data = data;\r\n }\r\n}<\/pre>\nIn the above code we have setData method. So it will try to put our JSON object as parameter for that method. But the variable “data” has array of objects as value. So we will create a java class with name Report and it will have “active”,”color”,”date”, “id” and “name” as it’s members. See below.<\/p>\n
package com.rajesh.json;\r\npublic class Report {\r\n private int id;\r\n private String name;\r\n private boolean active;\r\n private String date;\r\n private String color;\r\n public Report() {\r\n System.out.println(\"Inside Constructor with 0 arguments\");\r\n }\r\n public Report(int id, String name, boolean active, String date, String color) {\r\n this.active = active;\r\n this.id = id;\r\n this.name = name;\r\n this.color = color;\r\n this.date = date;\r\n }\r\n public int getId() {\r\n return id;\r\n }\r\n public void setId(int id) {\r\n this.id = id;\r\n }\r\n public String getName() {\r\n return name;\r\n }\r\n public void setName(String name) {\r\n this.name = name;\r\n }\r\n public boolean isActive() {\r\n return active;\r\n }\r\n public void setActive(boolean active) {\r\n this.active = active;\r\n }\r\n public String getDate() {\r\n return date;\r\n }\r\n public void setDate(String date) {\r\n this.date = date;\r\n }\r\n public String getColor() {\r\n return color;\r\n }\r\n public void setColor(String color) {\r\n this.color = color;\r\n }\r\n}<\/pre>\nIn Report.java we added getter and setter methods for each of the variables why because the struts framework by default will look for set\u00a0method for each variable. As we mentioned the parameter as List<Report> data in the setData() method it will create an object of Report,\u00a0then it will try to call setMethod for each variable like setColor(), setDate(),etc.,<\/p>\n
That’s all. Now we will initiate the action from the html file as below.<\/p>\n
<%@ page language=\"java\" contentType=\"text\/html; charset=ISO-8859-1\" pageEncoding=\"ISO-8859-1\" %>\r\n <!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/loose.dtd\">\r\n <html>\r\n\r\n <head>\r\n <meta http-equiv=\"Content-Type\" content=\"text\/html; charset=ISO-8859-1\">\r\n <title>Struts2 - JSON Example<\/title>\r\n <script type=\"text\/javascript\" src=\"js\/jquery.js\"><\/script>\r\n <script type=\"text\/javascript\" src=\"js\/base.js\"><\/script>\r\n <\/head>\r\n\r\n <body>\r\n <h2>Struts2 json & jquery - Demo<\/h2> <a href=\"javascript:sendJSONData()\">Write<\/a> \r\n <\/body>\r\n\r\n <\/html><\/pre>\nTo check the output see the output in the Eclipse console. In our example we just displayed in the console. If you want to process just replace those portion as per the need.<\/p>\n
Download the complete eclipse project below.<\/p>\n