Archive

Archive for May, 2011

Maven SkipTests command

May 29, 2011 Comments off
Categories: Maven

Running Maven jetty plugin with a different port

May 29, 2011 Comments off
Categories: Maven

Configuring Tomcat 6 For https (SSL)

May 27, 2011 Comments off
Prerequisites:-
1. JDK — i used¬†jdk 1.5.x
2. Tomcat 6.xFor any https (SSL) page a certificate is very necessary. First we will learn generating a keystore, which will contain a certificate chain. We will use the keytool command from JDK.

1. Goto the command prompt.

2. Type keytool -genkey -alias tomcat -keyalg RSA (if your path is not set to the java bin directory, please go there and type the command).

3. Now you will prompted for a keystore password give it as changeit (you can give it different but you will have to make some changes later).

4. Enter the details needed.

5. Now alias password will be aksed. It must be same as keystore password.

6. After the end of it a keystore will be generated in “drive”:\Documents and Settings\”username”\.keystore

Now configure “tomcat_home”\conf\server.xml, add the following code:-

You are done with your configuration. Save the server.xml file. Restart your tomcat. Now type https://localhost:8443This should show you the same tomcat homepage but in secured format.

Categories: General

how do I set eclipse.ini -vm option for m2Eclipse ?

May 24, 2011 Comments off

I installed maven plugin for eclipse, then I get an error like below:

please make sure the -vm option in eclipse.ini is pointing to a JDK

how to use -vm option to point to my jdk in eclipse.ini?

Solution:

add jdk javaw.exe file path as the first line to the eclipse.ini file and restart the eclipse.

-vm
C:/Program Files/Java/jdk1.6.0_24/bin/javaw.exe

Categories: Maven

Hyperic SIGAR API

May 23, 2011 Comments off
Categories: Hyperic SIGAR API

Spring Ajax Sample

May 18, 2011 Comments off
package com.mycompany.samples;

import java.util.Date;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloWorldController
{
@RequestMapping("/hello.html")
public ModelAndView helloWorld()
{
return new ModelAndView("hello", "message", "Spring MVC Demo");
}

@RequestMapping(value = "/time.html", method = RequestMethod.GET)
public @ResponseBody String getTime(@RequestParam String name)
{
String result = "Time for " + name + " is " + new Date().toString();
return result;
}
}
//hello.jsp
<jsp:useBean id="message" scope="request" type="java.lang.String" />
<html>
<head>
<title>Spring Ajax Demo</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
function doAjax() {
$.ajax({
url : 'time.html',
data : ({
name : "Vidya Sagar"
}),
success : function(data) {
$('#time').html(data);
}
});
}
</script>
</head>
<body>
${message}
<button id="demo" onclick="doAjax()" title="Button">Get the
time!</button>
<div id="time"></div>
</body>
</html>
//spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="com.mycompany.samples" />

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
</beans>
//web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

<display-name>SpringAjax</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
//index.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("hello.html"); %>

//project structure

Categories: Ajax, JQuery, Spring MVC
%d bloggers like this: