Differentiating between two browser clients for JSP application

E

Exceedingly

I have a JSP application that I would like to modify. This application
consists of an index page, a configuration page and a data page:
index.jsp - just a list of links - one for each of the following
pages
config.jsp - forms for setting colors, fonts, etc. and a "Save"
button
data.jsp - full set of data with scroll-bar

The config.jsp page allows the user to select a variety of settings
which are saved-to (and read-from) a server-side configuration file
(my.config) - so that when the application is re-launched the
previous user settings can be reasserted. These user selections are
applied to the look of the data pages.

Currently there is only one browser client accessing these pages. But a
second browser now needs to access these pages. This second browser
needs to have its own configuration settings (and related my.config
file) so that it can have its own look for its data pages. In other
words, each browser client wants to have its own set of configuration
settings and data-page look.

My question is this: What is the best way to keep track of which
browser is accessing the pages so that the correct configuration
settings can be used/retained (my1.config and my2.config or such)? I
need to know not only the best approach but the details of how to
implement it. This is an intranet application and as such I have full
control over the browser and server sides.

I need some way to provide an identifier to the application telling it
(the application) which browser is accessing the page. I am aware that
a parameter can be passed to a JSP page via the URL (although I would
need to know the details of implementing it). But is that the best way?
What about cookies (I don't know the details of implementing this
either)? Any other ideas?

Here are some further details:

- config.jsp is tied to Config.java which has the getters/setters for
each user-selectable setting as well as the read/write methods for the
my.config file.
<jsp:useBean id="myConfig" class="server.config.Config"
scope="application" />

- When any of the JSP pages are accessed the application looks for an
existing my.config file and, if found, reads it and sets the user
settings to reflect the contents of my.config. If the file does not
exist the user settings are set to predetermined defaults.
The JSP-Page:
<jsp:setProperty name="myConfig" property="filepath"
value="<%=
application.getRealPath("/WEB-INF") %>" />
The Corresponding Config.java methods:
public void setFilepath(String filepath) {
this.filepath = filepath;
if(!loaded) {
load();
} else {
Log.log("Not loading settings because they are
already loaded);
}
}

public boolean load() {
setDefaults();
boolean result = true;
try {
String fullpath = filepath + File.separator +
filename;
input = new FileInputStream(fullpath);
settings.load(input);
loaded = true;
input.close();
input = null;
} catch(IOException ioe) {
Log.log("Error loading settings: " + ioe, ioe);
result = false;
}
return result;
}

- When any of the pages are accessed the Config class is utilized to
provide that page with its required user-selected settings.
<jsp:useBean id="myConfig" class="server.config.Config"
scope="application" />
<jsp:useBean id="myData" class="server.data.MyData"
scope="application" />
myData.setSortOrder(myConfig.getSortOrder()); // typical

- When the "Save" button is clicked on the config.jsp page, the
Config class is utilized to save the settings to the my.config file:
The JSP-Page:
<%
if(request.getParameter("SaveButton") != null) {
myConfig.save();
}
%>

The Corresponding Config.java methods:
public boolean save() {
boolean result = true;
try {
String fullpath = filepath + File.separator +
filename;
output = new FileOutputStream(fullpath);
settings.store(output, "Video Wall Settings -
Generated File!");
output.close();
output = null;
} catch(IOException ioe) {
result = false;
Log.log("Error saving config file", ioe);
}
return result;
}

Any tips, documentation or examples you can direct me toward would be
appreciated. Thanks!!
 
E

Exceedingly

Can you tell me how to use cookies for this purpose - or point me to
some info?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top