Larry Nelsen

Greenhorn
+ Follow
since Mar 14, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Larry Nelsen

DUNS number: Is there a web service that provides DUNS number for company name?

There are web services that provide information given the DUNS number. I have a set of vendor name and addresses but no DUNS number.

Any ideas?
13 years ago
URL url = new URL("http://192.168.1.101:8080/servlet/PollerMaintenance");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);

BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
out.write("parameter1=value1¶meter2=value2");
out.flush();
out.close();
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );

String response;
while ( (response = in.readLine()) != null ) {
System.out.println( response );
}
in.close();
13 years ago

How do you call a servlet with HTTPConnection?

I can connect with
URL myURL = new URL("http:\\Server:8080\whatever\whatever.jsp);
HttpURLConnection con = (HttpURLConnection) myURL.openConnection();
con.setRequestMethod("POST");
con.setDoOutput(true);
con.connect();
// con.getResponseCode() returns 200 OK

How can it I con.submit("servlet/PollerMaintenance&Parameter1="value1"&Parameter2="Value2);
13 years ago
You can use the classes in java.net (such as URL and URLConnection), or a higher-level library such as HttpClient


I currently use URL and URLConnection to request my JSP page. I get my page with the output stream. How can I submit the page that is returned? Do I need a request object with a Request.submit?
13 years ago
OK
What class or classes should I use to call a servlet


This is basically my GUI method.
<form name="theForm" action="servlet/PollerMaintenance" method="POST">
<input type="hidden" name="Parameter1" value="Value1" >
<input type="hidden" name="Parameter2" value="Value2" >
document.theForm.submit();

My vendor won't help.
13 years ago
No.

The servlet processes records in a queue. There are four types of records in the queue. I need to pass a parameter to the servlet identifying the type of record to process. A return code would be nice. Currently i query a database to determine number of rows unprocessed. Zero rows means success.

I imagine the best way is to call the servlet directly with params. But I believe the servlet references request html fields for parameter values. The servlet is vendor supplied and I don't believe I have source code.
13 years ago
"why you have chosen to use GUI and client side technologies when neither are needed."

Paul, I am sure you are correct. I don't know how to call a servlet. I can view an existing JSP page and modify the code to automatically submit the form. I am using GUI and client side technologies because they provided a successful starting point. I am not familiar with RMI but it doesn't appear that I can call a servlet.

"submitting an HTTP request directly from Java. Have a look at the java.net package. "


I will look at the java.net.package again. Maybe the ContentHandler
13 years ago
"JSP creates HTLM, which requires something to interpret and display it. What are you intending to use instead of a browser? If there is nothing to display, would it not be better to just use RMI or something? "

Paul.
There is nothing to display. Daily a user logs on to a web server, navigates to a page and hits the submit button. I have created a jsp page which logson with javascripting, populates a couple fields, and then autmatically submits. The JSP page works great in my browser. The JSP page works great in VBScript if I instantiate a browser and call the JSP Page. But.. I need to run this on a UNIX server with no browser.
13 years ago
Hello.
I would like to execute a JSP page from a java client without a browser.

Sample.jsp
[begin code]-----------------------------------------------------------------------------
<%
. . .
// login
PassportLogon pl = new PassportLogon();
if (pl.isValidUser(userId, password, host, port, opsys) != true) { }
else
{
session.setAttribute("ConnectionEstablished", sConnectionInd);
%>


<html>
<body>
<form name="XXXXX" action="servlet/PollerMaintenance" method="POST">
Region: <%= request.getParameter("ppregion") %>
Touchpoint: <%= request.getParameter("TouchpointId") %>
Action: <%= request.getParameter("Action") %>
<input type="hidden" name="TouchpointId" value=<%= request.getParameter("TouchpointId") %> >
<input type="hidden" name="Action" value=<%= request.getParameter("Action") %> >
</form>
<script language="JavaScript" type="text/javascript">
document.XXXXX.submit();
</script>
</body>
</html>

<% } %>
<% } %>
[end code]-----------------------------------------------------------------------------



java client
[begin code]-----------------------------------------------------------------------------
. . .
String strURL = "http://" + Server_in + ":" + Port_in + "Sample.jsp" + params ;
URL myURL = new URL(strURL);
HttpURLConnection huc = (HttpURLConnection) myURL.openConnection();
huc.setRequestMethod("POST");

huc.connect();
OutputStream rawOutStream = huc.getOutputStream(); // I get the HTML page. BUT... FORM is NOT submitted automatically with the "document.WOTASK.submit();"
[end code]-----------------------------------------------------------------------------



Comments
What I can do:
I can connect ang get HTML page. BUT... FORM is NOT submitted automatically with the "document.WOTASK.submit();"
I can call Sample.jsp from my firefox web browser and the JSP page connects and submits page.
I can create a vbscript which instantiates a web browser class and the JSP page connects and submits page.

What I can not do:
Create a Java program which runs on a UNIX server that can connect to web server and call a JSP page which performs java scripting code.
No Browser application.

Is there a Java class which can be used to call&execute a JSP page within JAVA?

13 years ago