R
Roger
Hi all.
I've got servlets running in a chain. This works fine if users access
the servlets and JSPs. Now I'm trying to write a java class that can
emulate the browser, so that the applications runs without user
interaction.
I got the connection to work with authentification and I can access
the InputStream I get back, but I couldn't figure out how to access my
objects that I pinned to the session in my servlet chain.
(Startpage.jsp-->servlet-->output.jsp) The output.jsp accesses the
objects that were pinned to the session by the servlet.
I would now like to connect(better POST) to the servlet like the
Startpage.jsp does but from a java class. That would make my
application run without a browser having to connect...
------------java class code-----------------
String authString = "admin" + ":" + "admin";
String auth = "Basic " + new
sun.misc.BASE64Encoder().encode(authString.getBytes());
URL url = new URL("http://localhost:8080/Dummy");
URLConnection conn = url.openConnection();
conn.setRequestProperty("Authorization", auth);
System.out.println(conn.getInputStream().toString());
BufferedReader in = new
BufferedReader(new
InputStreamReader(conn.getInputStream()));
String line;
while((line = in.readLine()) != null) {
// process line
System.out.println(line);
}
------------/code--------------
This works find, but as mentionned I cant figure out how to access my
session objects, something that is aquivalent to
request.getAttribute(key) or request.getParameter within the servlet.
Can anyone help me or has got a hint?
Greets
Roger
I've got servlets running in a chain. This works fine if users access
the servlets and JSPs. Now I'm trying to write a java class that can
emulate the browser, so that the applications runs without user
interaction.
I got the connection to work with authentification and I can access
the InputStream I get back, but I couldn't figure out how to access my
objects that I pinned to the session in my servlet chain.
(Startpage.jsp-->servlet-->output.jsp) The output.jsp accesses the
objects that were pinned to the session by the servlet.
I would now like to connect(better POST) to the servlet like the
Startpage.jsp does but from a java class. That would make my
application run without a browser having to connect...
------------java class code-----------------
String authString = "admin" + ":" + "admin";
String auth = "Basic " + new
sun.misc.BASE64Encoder().encode(authString.getBytes());
URL url = new URL("http://localhost:8080/Dummy");
URLConnection conn = url.openConnection();
conn.setRequestProperty("Authorization", auth);
System.out.println(conn.getInputStream().toString());
BufferedReader in = new
BufferedReader(new
InputStreamReader(conn.getInputStream()));
String line;
while((line = in.readLine()) != null) {
// process line
System.out.println(line);
}
------------/code--------------
This works find, but as mentionned I cant figure out how to access my
session objects, something that is aquivalent to
request.getAttribute(key) or request.getParameter within the servlet.
Can anyone help me or has got a hint?
Greets
Roger