Posts

Showing posts from March, 2017

How Session Managment Works in servlet/jsp

/*  * To change this license header, choose License Headers in Project Properties.  * To change this template file, choose Tools | Templates  * and open the template in the editor.  */ 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; import javax.servlet.http.HttpSession; import java.sql.*; /**  *  * @author pandey  */ public class Registration extends HttpServlet {     @Override     protected void doGet(HttpServletRequest request, HttpServletResponse response)             throws ServletException, IOException {         PrintWriter out = response.getWriter();         HttpSession hs = request.getSession();    ...

Java Experiance InterView Questions and answer

--> Example of SingleTone in java  public final class SingleTone {         /**      * @author anand      *      */             public static SingleTone single;     //Can be act as SingleTone or make constructor as private         private SingleTone(){}         public static synchronized SingleTone getInstance(){                 if(single==null){                         single=new SingleTone();         }         return single;     }     } --> What is difference between StringBuffer and StringBuilder in Jav...

Scheduler JOB in java

package com..scheduler; import static org.quartz.CronScheduleBuilder.dailyAtHourAndMinute; import java.util.Calendar; import org.quartz.Job; import org.quartz.JobBuilder; import org.quartz.JobDetail; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.quartz.Scheduler; import org.quartz.SchedulerException; import org.quartz.Trigger; import org.quartz.TriggerBuilder; import org.quartz.impl.StdSchedulerFactory; public class SchedulerTest implements Job {     public static void main(String[] args) {         int HOUR_OF_DAY = Integer.parseInt("20");         int MINUTE_OF_HOUR = Integer.parseInt("10");         Trigger trigger1 = TriggerBuilder.newTrigger().withIdentity("test trigger1", "group1").withSchedule(dailyAtHourAndMinute(08, 00)).build();         Trigger trigger2 = TriggerBuilder.newTrigger().withIdentity("test ...

How to write Scheduler in Java

import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; /**  * This Class is Used to Run Every after 15 min  *  * @author ananddw  **/ public class TestScheduler{     public static void main(String[] args) {         new TestScheduler().start();     }     public void start() {         System.out.println(" scheduler starts");         Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {             @Override             public void run() {                 try {                     //Need to Call Your Method which will execute every after 15 min     ...

how to get src value from normal Text in javascript

<html> <head> </head> <title>|| Video Uploader || </title> <body> <input type="text" id="video_url" name="video_url" value="<iframe   width='420' height='315'    src='https://www.youtube.com/embed/XGSy3_Czz8k'></iframe>"  /> <button id = "opener" onclick="insertURL()">Show URL </button> <script type="text/javascript"> <!-- If User's Provide direct URL or Full iframe innerhtml-->     function insertURL(){         var ishare_url = document.getElementById("video_url").value;                 if(undefined!==ishare_url.split('src=')[1]){         var src = ishare_url.split('src=')[1].split(/[ >]/)[0];         if(src){             var decode_ishare_url = decodeUR...