Posts

HTTP Status 405 - HTTP method GET is not supported by this URL

When I'm working with Java Servlet, I encountered "HTTP Status 405" error. But code seems to legit. The problem was, servlet doGet method calling super method. package uk.co.andromedatech.onlineradio; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Test extends HttpServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub super.doGet(req, resp); resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.println("Leann...."); } } After removal of red marked code selection, servlet compiled and started to work.

C# - List all the links in a website.

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Net; using System.Text.RegularExpressions; namespace ProgrammingDotNet {     class Program     {         public static void Main(string[] args)         {             StreamReader reader = null;             try             {                 WebRequest request = WebRequest.Create("http://www.techexams.net/");                 WebResponse response = request.GetResponse();                 reader = new StreamReader(response.GetResponseStream());                 string content = reader.ReadToEnd();       ...

C# - Simple program that dumps text files to the windows console.

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProgrammingDotNet {     class Program     {         public static void Main(string[] args)         {             String filename = "C:\\Users\\Isuru\\Desktop\\google_5000000.txt";             StreamReader reader = new StreamReader(filename);             for (String line = reader.ReadLine(); line != null; line = reader.ReadLine())             {                 Console.WriteLine(line);             }             reader.Close();             Console.ReadLine();         }     } }

Unable to get system library for project

Image
You may not able to build your android project because android adt cannot find the system library for project. And following compile errors may occur due to that problem. The type java.lang.Object cannot be resolved. To solve the problem open build path for the project, and in Android tab select different project build target.

SQLite For Android Source Codes

public class SQLiteHelper extends SQLiteOpenHelper { private static final String DATABASE_NAME = "my_database.db"; // TOGGLE THIS NUMBER FOR UPDATING TABLES AND DATABASE private static final int DATABASE_VERSION = 1; // NAME OF TABLE YOU WISH TO CREATE public static final String TABLE_NAME = "my_table"; // SOME SAMPLE FIELDS public static final String UID = "_id"; public static final String NAME = "name"; SQLiteHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + UID + " INTEGER PRIMARY KEY AUTOINCREMENT," + NAME + " VARCHAR(255));"); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { Log.w("LOG_TAG", "Upgrading database from version " + oldVersion + " to " + newVersion + ", ...

[Android] Make android button transparent.

You can make android button transparent by inserting following code in layout xml file. android:background="@android:color/transparent" For example, I used it in one of my button as following. <Button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignParentLeft="true"         android:layout_alignParentRight="true"         android:layout_alignParentTop="true"         android:text="Who is computer Geek?"         android:background="@android:color/transparent" />

CSS Basics

Making bold the whole paragraph. <p style="font-weight: bold;">This is a bold paragraph.</p> Making a word italic. This is the <span style="font-style:italic;">greatest</span> web page I’ve made yet. Using an internal style sheet. <!doctype html> <html> <head> <title>Using an internal style sheet.</title> <style type=”text/css”> div {       font-weight: bold; } span {       font-style: italic; } </style> </head> <body>             <div>This is my web page.</div> </body> </html> Using an external style sheet. <link rel="stylesheet" type="text/css" href="path_to_style_sheet/style.css">