Friday, March 12, 2010

Getting the security less application ready

1> Add jstl.jar (version 1.1 i guess) to your WEB-INF/lib folder
2> Modify index.jsp as shown below
Listing 1 - index.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" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Sky Photos home</title>
</head>
<body>
<h1>Welcome to Sky Photos</h1>
<p>Not an user yet? <a href="#">Register</a></p>
<p><a href="viewphotoupload.html">Upload Photo</a></p>
</body>
</html>

3> Add a controller for the landing or index page.
Listing 2 - EntryController.java

/**
*
*/
package org.opengarage.skyphoto.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* @author dhrubo
*
*/
@Controller
public class EntryController {

@RequestMapping("/index")
public String viewLanding(){
return "index";
}
}


4> Add a controller for the upload page view
Listing 3 - UploadController.java
/**
*
*/
package org.opengarage.skyphoto.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* @author dhrubo
*
*/
@Controller
public class UploadController {
@RequestMapping("/viewphotoupload")
public String viewPhotoUpload(){
return "upload";
}
}

5> Time to launch the browser and test it on the browser.


6> Click on upload photo, you will see it is accessible to any one. But only logged on users should be able to access that page.



In the next post I will start with the first step to ensure that a user is logged in / signed in before he or she can access the upload photo page.

0 comments:

Post a Comment