Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Framework

guillermo luque
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote two application (app1 and app2) and they are related as follow after singin in app1 go to app2 (Session aware)

app1 is written in Spring and Hibernate and app2 is written in Jsp , servlet and hibernate
app2 handles a session with HttpSesion.

I am trying to convert app2 to Spring and I got some problems trying to handle session in Spring
and I decided to handle in this way

1.- the way I handle session in the current app2 is

1.1 I create a session with HttpSession and ServletContext objects after sign in and in all servlets I put this code to
control the session.

HttpSession session = ((HttpServletRequest)req).getSession();
LoginProcessor loginprocessor = (LoginProcessor) getServletContext().getAttribute("loginprocessor");
UserInfo userinfo = (UserInfo)session.getAttribute("userinfo");
if (userinfo == null) {
userinfo = new UserInfo();
userinfo.setUser (" ");
userinfo.setPassword (" ");

if (!loginprocessor.alreadyLoggedIn(userinfo)) {
} else {
userdata = (UserDataBean)session.getAttribute("userdata");

This works fine with Session and Servletcontext object

2.- Now when I am converting to Spring app2 I also create a Session after sign in with servlet

The hiperlink that is working with spring has this problem

public class IndexWepApplication extends AbstractController {
String sTxt;
String welcome;
String first;
HttpServletRequest req;
HttpServletResponse res;
boolean id_found;
ServletContext context;
String nextPage;
boolean stop;
private UserInfo sessionUserinfo;
* Responsible for translating a web request into a ModelAndView object for presentation

protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse res)

1-. HttpSession session = ((HttpServletRequest)req).getSession();
2.- LoginProcessor loginprocessor = (LoginProcessor) getServletContext().getAttribute("loginprocessor");
3.- UserInfo userinfo = (UserInfo)session.getAttribute("userinfo");

In execution time I got casting error in (2) and (3) I checked the session object in Elipce and it has all
userinfo and loginprocessor objects stored in the session object.

and when I clicked hyperlink in app2 with a servlet workes fine

I did many things to try to figure out the problem but It did not work out.

Any sugestion

Thank you.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic