Sample multithreading program using Callable Interface

Step 1: Create “” and paste the below code, package runnableandcallable; import java.util.ArrayList; import java.util.Collection; import java.util.List; import runnableandcallable.CallingThread; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class MainThread{ private static ExecutorService service = Executors.newFixedThreadPool(10); //connection pool @SuppressWarnings("unchecked") public static void main(String[] args) throws InterruptedException { List<CallingThread> threads = new ArrayList<CallingThread>(); //ArrayList to store the threads with CallingThread Type CallingThread ct

194 total views, no views today

» Read more

Auto Refresh in All Browsers

If you use, <% response.addHeader(“Refresh”,”4;account.jsp”); %> in jsp page, the page will be redirected to account.jsp from the current page after 4 seconds. Note: The above operation would happen in all browsers except internet explorer and eclipse internal browser. To Perform Auto Refresh in all browsers: <%String autoRefresh=”accounts.jsp” %> <meta http-equiv=”refresh” content=”5;URL=<%=(autoRefresh)%>” /> Now After 5 seconds page will be

169 total views, no views today

» Read more

Passing Console output from java to jsp

Step 1: Create and paste the below code,   package com.agn; public class Hello { /** * @param args */ public String returning(){ String go = "hello Naveen"; return go; } public static void main(String[] args) { Hello h = new Hello(); System.out.println(h.returning()); } }   Step 2: Create fethingfromjava.jsp and paste the below code,   <%@ page language="java"

1,603 total views, 1 views today

» Read more

Converting Numbers to Words in Java

Step 1: Download the program and save it as package pack; import java.util.ArrayList; import java.util.List; public class Naveen { public static void main(String[] args) { String[] zerotonineteen={" zero"," one"," two"," three"," four"," five", " six"," seven"," eight"," nine"," ten"," eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"}; String[] tens ={"","","

118 total views, 1 views today

» Read more

Perl System values to variables

In perl you can easily assign the system (“some commands”) values to variables using the  Capture::Tiny Module. Step 1: Download the Capture::Tiny Module from cpan. Step 2: Extract the downloaded file and go into that and run perl Makefile.PL make  make run make install  commands to install. Step 3:  Example program. use strict; use warnings; BEGIN {required Capture::Tiny; }

161 total views, no views today

» Read more

Passing Checkbox values from one jsp to another

1.jsp:   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" ""> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form method="post" action="2.jsp"> My Favourite Colors are <input type="checkbox" name="cb1" value="blue">Blue <input type="checkbox" name="cb1" value="green">Green <input type="checkbox" name="cb1" value="Yellow">Yellow <input type="checkbox" name="cb1" value="Red">Red <input type="checkbox" name="cb1" value="white">White <input type="submit"> </form> </body> </html>  

239 total views, no views today

» Read more
1 2