Thursday, January 3, 2013

Simple Form post from Codebehind C#

Here is the sample code:
private void PostToUrl(string url, string parameters)
{
string URI = url;
string myParameters = parameters;//"param1=value1&param2=value2&param3=value3";

using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
string HtmlResult = wc.UploadString(URI, myParameters);
}
}

Select an element from xml file using where clause

Here is the sample xml file
<?xml version="1.0" encoding="utf-8" ?>
<urls>
<url keyword="RA">http://google.com </url>
<url keyword="NC">http://google.com </url>
</urls>

Here is the sample code
XDocument doc=XDocument.Load(Server.MapPath("~/urllist.xml"));
var url = (from ur in doc.Descendants("url")
where ur.Attribute("keyword").Value=="RA"
select ur.Value).ToList();

Thursday, December 27, 2012

Upload file using JSP

I found a good article to upload a file using jsp here . I just modified it little so that it can upload file to the root directory of the webapp.

fileindex.jsp

<%@ page language="java" %>
<HTml>
<HEAD><TITLE>Display file upload form to the user</TITLE></HEAD>
<% // for uploading the file we used Encrypt type of multipart/form-data and input of file type to browse and submit the file %>
<BODY> <FORM ENCTYPE="multipart/form-data" ACTION="single_upload_page.jsp" METHOD=POST>
<br><br><br>
<center><table border="2" >
<tr><center><td colspan="2"><p align="center"><B>PROGRAM FOR UPLOADING THE FILE</B><center></td></tr>
<tr><td><b>Choose the file To Upload:</b></td>
<td><INPUT NAME="F1" TYPE="file"></td></tr>
<tr><td colspan="2"><p align="right"><INPUT TYPE="submit" VALUE="Send File" ></p></td></tr>
<table>
</center>
</FORM>
</BODY>
</HTML>

Tuesday, December 25, 2012

jsp with beans example

Here is an example :

index.jsp
---------------------

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="us" scope="request" class="msgbean.User"></jsp:useBean>
<%
if (request.getParameter("Name") != null) {
//out.write(request.getParameter("Name"));
us.setName(request.getParameter("Name"));
us.setEmail(request.getParameter("Email"));
}
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<form method="post">
<table>
<tr><td>Name:</td><td><input type="text" name="Name"/></td></tr>
<tr><td>Email:</td><td><input type="text" name="Email"/></td></tr>
<tr><td><input type="submit" value="Submit"/></td></tr>
</table>
</form>

You entered:<br />

Name: <%= us.getName()%></br>
Email: <%= us.getEmail()%></br>
</body>
</html>
----------------------------------

Sunday, November 25, 2012

Get number of element of specific name in a xml file

XmlDocument xdoc = new XmlDocument();
xdoc.Load(Server.MapPath("~/pp1.xml"));
string PersonCount = xdoc.DocumentElement.SelectNodes("//persons/person").Count.ToString();
Response.Write(PersonCount);

Tuesday, October 16, 2012

ওয়ালটন প্রিমো (অ্যান্ড্রয়েড) রিভিউ

আমি নিজে অনেকদিন থেকেই সনি এরিকসন এক্সপেরিয়া এক্স এইট চালাই। এক বন্ধুর জন্য গত শনিবার গেলাম এন্ড্রয়েড ফোন কিনতে। প্রথমে ভেবেছিলাম যে সিম্ফোনি w5 নিবো কিন্তু পরে নেট ঘেটে দেখলাম যে দাম এবং কনফিগারেশনের দিক থেকে ওয়ালটন প্রিমো এগিয়ে। কিনলাম ওয়ালটন এর বিজয় সরনী এর শো রুম থেকে। কেনার পর একদিন ব্যবহার করার সুযোগ পেলাম। তাতে যা দেখলাম টাকার হিসেবে অসাধারন জিনিস (আমার মতে)।

Monday, September 24, 2012

Make your windows 7 laptop into wifi hotspot

Make sure you have installed Microsoft Virtual Wifi miniport adapter

 

Then make command as follows:
C:\Windows\system32>netsh wlan set hostednetwork mode=allow ssid=MyWifi key=password keyUsage=persistent

To start your network
C:\Windows\system32>netsh wlan start hostednetwork

To Stop your network
C:\>netsh wlan show hostednetwork

Share your internet connection by going to network sharing center





What is DaemonSet in Kubernetes

 A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...