• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring Framework

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)) {
res.sendRedirect("project_one/ControlAccess/SessionEnded.jsp");
} 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.






 
reply
    Bookmark Topic Watch Topic
  • New Topic