0

I have a web app that shows a list of online users. The user may select one other user from that list to connect to, which, brings it to a new page. This new page will be where the users "connect" (using WebRTC). For my connection method I need the user ID from both users. I have obtained these ID's in the one page. My problem is I need to pass these ID's to the next page. Some methods I thought of include:

  • Database table containing both users. Then I can access either through an ajax call to a REST Web Service or through a backing bean.
  • Passing variables to some form of local storage.
  • Passing the variables into the URL somehow.
  • Use AJAX to change the view to next page view (entire view change?)

But I'm not sure if there's a better way to achieve this. What would be the most efficient way of knowing which user they selected (by using their ID's) so they can connect within the next page?

chRyNaN
  • 3,592
  • 5
  • 46
  • 74
  • If the user ID isn't sensitive information, I would pass them as URL parameters. Simple, and adds a "feature", whereby you could manually input the IDs in the url. – elzi Nov 06 '14 at 22:07
  • Interesting, any ideas on how large web apps solve a problem like this? For instance, Facebook. Perhaps, just a different way altogether. I know they use their "big pipe" method for transferring information from the backend to the frontend. – chRyNaN Nov 06 '14 at 22:27
  • Looking at request logs using google hangouts, every time you open a chat window it makes a POST to a client handler with headers I imagine are specific to the user(s). Obfuscated to all hell in production, though. – elzi Nov 06 '14 at 22:37

1 Answers1

0

Passing information in the URL is very susceptible to hacking. Probably the easiest method and most robust would be to use beans

JSP

<html>
    <head><title>Hello JSP</title></head>
<body>
<%! String name, email; %>

<jsp:useBean id="hello" scope="session" class="greetings.HelloBean" />

<jsp:setProperty name="hello" property="name" value='<%= request.getParameter ("name") %>'/>
<jsp:setProperty name="hello" property="email" value='<%= request.getParameter ("email") %>'/>

<% 
    name = hello.getName();
    email = hello.getEmail();
    out.println ("<h3>Hello, your name is " + name);
    out.println (" and your email address is " + email + ".</h3>");
%>
</body></html>

Bean

public class HelloBean
{
    private String name = "";
    private String email = "";

    public String getName() {return name;}
    public String getEmail() {return email;}

    public void setName (String n) {name = n;}
    public void setEmail (String e) {email = e;}
} // HelloBean
Abercrombieande
  • 679
  • 6
  • 12