The following Java Servlet shown below helps you determine whether your Browser Cookie Setting is On/Off; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class CheckCookieServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); // If this is the first request to your Browser if (request.getParameter("cookieFlag") == null) { Cookie cookie = new [...]
Continue reading...14. October 2008
Java Program: This program creates a JLabel with a HyperLink. If you click on this link, a browser will open with the adress embeded. package javaapplicationmodels; import java.io.IOException; import javax.swing.*; import java.awt.*; public class JLabelLink extends JFrame { private static final long serialVersionUID = 1L; public JLabelLink() { super() ; setTitle( "Click on the JLabel to start the webpage." ) ; setDefaultCloseOperation( [...]
Continue reading...6. October 2008
How to Setup or Configure Oracle JDBC Connection with Tomcat 5.5 Below are 3 Steps to Create a JDBC Connection for Tomcat using Oracle driver Step 1: Copy The Necessary Jars To begin with You need to copy the Jars namely classes12.jar and classes111.jar from your Oracle Installation to your Tomcat 5.5 Common Lib Folder. Oracle 9i Path to [...]
Continue reading...25. August 2008
Fibonacci Series This Program generates Fibonacci series for a given number of times. Output: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 public class FibonacciSeries { /* * Generates the Fibonacci Series */ public void generateSeries(int num) { int f1, f2 = 0, f3 = 1; System.out.println("fib(0) = " + f2); for (int i = 1; i <= num; i++) [...]
Continue reading...17. August 2008
Here is a Sample Program which creates a Context menu or a Popup menu on a JTable. Features of this Program: 1) A PopUpMenu appears when you right click on the JTable on the rows and on the table header. 2) You can add a row and delete a row in the JTable from the PopUpMenu. import java.awt.*; import javax.swing.*; import [...]
Continue reading...
26. October 2008
1 Comment