Ads Inside Post

Search in This Blog

Post Xml data without form in JSP and receive

How to post xml data in JSP page without form field and get it's data
in the next JSP page.

The first file post-data.jsp is just taking xml data form xml file and
sending xml data as a post to the get-post.jsp page.

first file is:

< %@ page import="*" % >
< %@ page import="*" % >
< %@ page import="java.util.*" % >
< %@ page import="java.text.*" % >
< %
URL u;
u = new URL("http://localhost:9292/post/get-post.jsp");
// get the xml data from xml file which you want to post
String inputFileName="C:\\temp1.xml";
FileReader filereader =new FileReader(inputFileName);
BufferedReader bufferedreader=new BufferedReader(filereader);
String initial=bufferedreader.readLine();
String finalData=new String();
String s=(finalData.toString());
HttpURLConnection uc = (HttpURLConnection)u.openConnection();
uc.setRequestProperty("Content-Type", "text/xml; charset=\"utf-8\"");
DataOutputStream dstream = new DataOutputStream(uc.getOutputStream());
InputStream in = uc.getInputStream();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
StringBuffer buf = new StringBuffer();
String line;
while ((line = r.readLine())!=null) {
catch (IOException e)
% >

Second file is:


< %@ page import="java.util.*" % >
< %
String postedData = request.getReader().readLine();
///// perform here your operation for postedData
out.println("Posted Data is ");
% > 

Add html tag dynamically in html

Add html tag dynamically in html

<script src="jquery-2.1.1.js" language="javascript" type="application/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var ID = 1;
        function addRow() {
            var html =  '<tr>' +
                        '<td>Name: <input type="text" name="aa' + ID + '" /></td>' +
                        '<td>File: <input type="file" name="fileUpload' + ID + '" /></td>' +
                        '<td><input type="button" class="BtnPlus" value="+" /></td>' +
                        '<td><input type="button" class="BtnMinus" value="-" /></td>' +
        $("#Table1").on("click", ".BtnPlus", addRow);
        function deleteRow() {
            if(ID==1) return;
            var par = $(this).parent().parent();
        $("#Table1").on("click", ".BtnMinus", deleteRow);
<table id="Table1" cellspacing="3">
        <td>Name: <input type="text" name="aa0"  id="aa0" /></td>
        <td>File: <input type="file" name="fileUpload0"/></td>
        <td><input type="button" class="BtnPlus" value="+" /></td>
        <td><input type="button" class="BtnMinus" value="-" /></td>

Display content with delay in jquery

Display content with delay in jquery

Some time you want to show some data with delay, then use the listed below code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display content with delay</title>
.my-class {
    display: none;
<script language="javascript" src="jquery-1.10.2.js" type="text/javascript"></script>
<div class="my-class">
$(document).ready(function() {

Fieldset in html

Fieldset example in html
Fieldset is very useful to combine the more than one information which you want to show or
feed data entry. actually it will block the more than one columns (all colums will be shown in one
box with header heading).

<fieldset style="text-align:right; width:300px;" accesskey="c">
<legend><b>Address Details</b></legend>
Name <input type="text" size="50" /><br>
Address <input type="text" /><br>
City <input type="text" /><br>
State <input type="text" />

Sum datagridview cell by button click c#

If you have enter many records in datagridview in c# winform and want to show the sum of any cell values for example: "mark" cell, then you needed to retrieve each datagridview row and add it's value in other variable.... but we want to do this not using iteration.. thwn what we will do?

Use listed below code to achieve target:

string m = "Total Marks =" + dataGridView1.Rows.Cast<DataGridViewRow>().AsEnumerable()                                                    .Sum(x => int.Parse(x.Cells["mark"].Value.ToString())).ToString();

Sort Datagridview column by button click c#

Sort Datagridview column by button click c#

If you have added the random records in your Datagridview C# winform and want to show records by any column on button click then use this:

dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Ascending);
dataGridView1.Sort(dataGridView1.Columns["mark"], ListSortDirection.Ascending);

"mark" is the cell name in the datagridview.

Image rotate in jQuery

Image rotate in jQuery

<!DOCTYPE html>
<script type="text/javascript" src="jquery.js"></script>
<img style="transform: rotate(285.4deg);" id="myimg"  src="WOW.jpg">
<script type="text/javascript">
    jQuery(function($) {
        $(document).ready(function() {
            window.imagerotate = function () {
                                callback: imagerotate,
                                //t: current time,b: beginning value,c: change in value,d: duration
                                easing: function (x,t,b,c,d) {
                                    return c*(t/d)+b+10000;
                        setTimeout('imagerotate()', 1000);

Send Files to IP address in C#

If there are you situation you want to send file to IP address,
then use listed below code:

string sourceDir = @"C:\\tt";
string destIP = @"\\\shared-folder-amit";
string[] sourceFiles = Directory.GetFiles(sourceDir, "*", SearchOption.AllDirectories);
foreach (string files in sourceFiles) {
  string localFile = files.Replace(sourceDir, "");
  if (!Directory.Exists(Path.GetDirectoryName(destIP + "\\" + localFile)))
    Directory.CreateDirectory(Path.GetDirectoryName(destIP + "\\" + localFile));
  File.Copy(files, destIP + "\\" + localFile, true);

CodeIgniter Undefined property CI_Loader $session codeigniter error


If you works in CodeIgniter and play with session then you can get this error message :
Undefined property: CI_Loader::$session

CodeIgniter Undefined property CI_Loader $session codeigniter error

A PHP Error was encountered CodeIgniter
CodeIgniter error

 Severity: Notice
Message: Undefined property: CI_Loader::$session


It means that you have not loaded session library in it controller's index or constructor as


To prevent this error message use listed below code:

public function index() {

selected check box record from DataGridView c# winform

Suppose you have a DataGridView with the check box. Data are showing and you want to store only those data that's check boxes is selected, so what you will do? In simple you will use the loop which will retrieve all data from DataGridView from first row to last row and in that loop check the condition is which rows’s check box is selected.

It is a good way but not a smart way, imagine that there are 99999999 rows in the DataGridview and only 100 rows are selected.

Smart way is only create a loop which iterate only 100 times not for 99999999 times.

The Smart way is listed below:
1) Assume that we have the DataGridView with records and also have the check box and its name is "selectMe".

2) use listed below code to retrieve only selected checkboxes.

List<DataGridViewRow> list = dataGridView1.Rows.Cast<DataGridViewRow>().Where(eachrow => Convert.ToBoolean(eachrow.Cells["selectMe"].Value) == true).ToList();
foreach (var row in list) {