• 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

How To Use Session Scope Data In a Different Web-Application?

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ticketbookingapp:
===================
package com.ticketbookingapp.servlet;

import java.io.IOException;
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 com.ticketbookingapp.dto.UserInfo;

public class BookTicketServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String name = request.getParameter("username");
String password = request.getParameter("password");
System.out.println(name);
System.out.println(password);

UserInfo info = new UserInfo();// Instantiating DTO
info.setName(name);
info.setPassword(password);

HttpSession session = request.getSession();
session.setAttribute("details", info);

response.sendRedirect("http://prasad-pc:8080/xxxxbankapp/index.jsp");//Redirecting To Another Application Which Is Running On Same Server....From xxxxbankapp index.jsp, When Click On Submit It Invokes ValidateUserDetails Servlet...
}

}
=============
xxxxbankapp:
============

package com.xxxxbankapp.servlet;

import java.io.IOException;
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 com.ticketbookingapp.dto.UserInfo;

public class ValidateUserDetails extends HttpServlet {

private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

HttpSession httpSession = request.getSession(false); //Here I am Getting Session Object...
if (httpSession != null) {
System.out.println("Got Session Object..");
UserInfo info = (UserInfo) httpSession.getAttribute("details");

if (info != null) { // Here I unable to get Userinfo Object
System.out.println("Got UserInfo Object...");
System.out.println(info.getName());
System.out.println(info.getPassword());
request.getRequestDispatcher("/userLoginSucess.jsp").forward(
request, response);
} else {
request.getRequestDispatcher("/userLoginFailure.jsp").forward(
request, response);
}
}else{
System.out.println("Unable Get Session Object..");
}

}

}
output:
Got Session Object.. and It Will Redirect to userLoginFailure.jsp...

I want To Send Data from ticketbookingapp to xxxxbankapp in secure way.. How Can I Send?


Thank You Very Much For spending Your Valuable Time .
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The session scope cannot surpass the application scope. So there is no scope shared by multiple applications, even on same server.
You can add the field in the request and submit the request to the second application, send it as hidden field, query parameter,etc.

Only making use of session does not make the data transfer "secure". It should be using SSL, or field encryption for sensitive fields.
 
prasad boini
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic