How to submit a HTTP Request from a Java Program
I am working on an web based application where in I need to submit the HttpRequest through a Java Program and not through browser. Moreover my intent is just to submit the HttpRequest. I donot want to wait for the response to come back. I have used the URL Connection class to do the same and I am trying to post this request. The contents of the methods that I am using are as below:-
public void doPost(URL url, String inputXMLString) throws IOException
//Create URLConnection based on the passed URL
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(false);
connection.setUseCaches(false);
connection.setAllowUserInteraction(false);
connection.setRequestProperty("Content-type", "application/x-www-form-
urlencoded");
//Get the Connection's output stream and write the request to it.
PrintWriter out = new PrintWriter(connection.getOutputStream());
out.print("&ena-request-input=" + URLEncoder.encode(inputXMLString));
out.flush();
out.close();
Call to the above method does not invoke the URL I am intending to submit the request at.
Can anybody give me the clue....................................................?
I agree with the advice to launch a new thread to read and ignore the response. I don't think you should have to do it to make it work, but it's worth trying for two reasons:
1) If it turns out it does make it work, well, then either you can leave it that way, or use that as a clue to help figure out how to make it work the way you want.
2) There may be an error message there that will give you an idea why it's not working.
When you say it's not invoking the servlet, what does that mean, and how do you know? Is it just that the final results aren't being seen? Put a bunch of logging statements in the servlet. It could be that it's getting hit, but you're corrupting the string you're building, or sending some extra junk that it can't handle. Spit out a log statement from the start of doPost, to see if it's even getting there. Then log the parameter. Enclose the output in quotes or braces or something to make sure there's not extra junk. I've had XML docs not parse because there was a blank line at the beginning.
If it works in the browser but not from your standalone app, then you need to have the servlet tell what difference it sees in the two cases. Print out headers, other params, everything you can think of.
Re-read the docs for URL, HttpURL, whatever, to make sure you're doing all the right steps in the right order. Make a servlet that just takes a single, simple param=value via POST and see if you can get that to work.
Similar Messages
-
How to submit a concurrent request from Discoverer report.
I would like to know If any one has tried submitting a concurrent request from Discoverer Report?_
This is no stupid question, but our team here finally decided with a solution to our long pending issues with few of the discoverer report. To Proceed further, we would like to know, how to submit a concurrent request from Discoverer report?
We are looking for calling a package from the Disco admin by passing the parameters from the disco to the 6i report.
All help us in this regards are much appreciated.
Kindly help us in the same!
Thanks
ArunThanks Rod for confirming the same.
I will be trying the same today and will let you know if I succeed in doing it.
If I can share the actual requirement with you, it goes like this.
"I will be triggering the Oracle 6i standard AP Trail balance report through the Disco report. The standard report will be inserting the required data to one of my custom table. Once the concurrent program completes normal, my custom table will be having the required data to create the workbook specific to the current run of the concurrent program.
The one problem which I think could happen is, How can I make my disco report to wait till the standard program to complete in normal so that my disco report can be generated with the data from custom table.
Will the above requirement is possible If I follow the way you mention in the PDF or Could you suggest a better way for achieving the same.
In short, my requirement is: The custom table(say XX_TABLE) will be populated with data when the standard 6i report is run and the disco admin will be making of the custom table (XX_TABLE) to generate the report.
Please advice.
Thanks
Arun -
How to transfer the http request from applet to servlet/jsp
I use the JTree component to create a navigation of a website,but i don't
know how to connect the tree's nodes with the jsp/servlet.
I mean how to transfer the http request from the applet to a jsp.
I use the "<frameset>" mark which will divide the web browse into 2 blocks.
The left side is Applet,and the right side is the linked jsp page.
what I say is as the weblogic console layout.
who can help me!!!
Thank You!I use the JTree component to create a navigation of a website,but i don't
know how to connect the tree's nodes with the jsp/servlet.
I mean how to transfer the http request from the applet to a jsp.
I use the "<frameset>" mark which will divide the web browse into 2 blocks.
The left side is Applet,and the right side is the linked jsp page.
what I say is as the weblogic console layout.
who can help me!!!
Thank You! -
How to call j2me emulator instance from a java program?
hi,
how to call j2me emulator instance from a java program?
i tried public void startApp(){
try{
platformRequest("tel:+5550000");
}catch(Exception e){
e.printStackTrace();
from a j2me midlet itself,
but it gave illegal access exception.
do i need any hardware phone connected to my pc?
please help.http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
import java.util.*;
public class OpenExplorer{
public static void main(String args[]){
new OpenExplorer();
public OpenExplorer(){
try{
String command = "explorer C:";
// or String command = "cmd /c explorer C:";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command);
int exitVal = process.waitFor();
System.out.println("Exit Value: " + exitVal);
} catch(Exception e){
e.printStackTrace();
} -
How to display a oracle table from a java program?
How to display a oracle table from a java program.
Hello friends, I have written a Java program, using oracle 10g as backend.
I want to display a oracle table as output. Im not getting how to display oracle table as a output table.. Pls help me
Thank youjayanthds, you're not going to get a satisfactory
answer to this here. it's too big a task to justbe
quickly outlined in a forum - the reply "all youneed
to do is to query you table and return it asJTable"
is worthless, for example, since the solution to
any problem can be distilled to such a
soundbite, if need be. doesn't make the solutionany
simpler
essentially you're asking "how do I write adatabase
application?". all you'll get is snippets of code
that, when fitted together, will eventually helpyou
do this, but you'll spend days and days comingback
saying "right, I've done that, now what?" until
either you or the forum gets frustrated with the
whole affair and the process stops
there are entire books written about this subject,
and countless tutorials and guides on theinternet.
you're better off going down that routehehehe.well, it's true! I used to have a manager that would outline the solution to a problem in a few lines of pseudocode, and then firmly believe that the actual solution would be just as brief and simple. shame his pseudocode included such lofty abstractions as "reformat all data" -
How to run a openssl command from a java program
Hi All
Please suggest on how to run a openssl command from a java program.
I am using this
Runtime runtime = Runtime.getRuntime();
runtime.exec("openssl pkcs8 -inform der -nocrypt test.der result.pem");
This is suppose to take test.der as input and create result.pem.
There are no errors but the file result.pem isnt created.
Thanks in AdvanceFirst off is that openssl command correct? Should it be this instead:
openssl pkcs8 -inform der -nocrypt -in test.der -out result.pem
Try out your openssl command within a command prompt so that you know that it works ok. I think the command line you specified waits on stdin (well it does for me).
After that.....
runtime.exec creates a Process object. If you do this:
Process openssl = runtime.exec("....")
then you can examine the return code from openssl to see the exit code - for instance if the input file does not exist then exit = 1. You can test for this with Java
Alternatively you could get the stderr from the process and look inside it - if it is 0 length then all is good, if it has some text in there then it has likely failed. You could then throw an exception and include the stderr output in the exception messgae. You may need to experiment with this, runnig it first when openssl is happy then running it again when openssl is upset.
M -
How to submit a concurrent request from a button in Selfservice
Hi,
I hope this is the forum where to start.
I want to submit a concurrent request when a button is pushed in selfservice.
I've implementend the event for button in java and its woring fine, but how to submit a conurrent request in java?
Can anyone help me or tell me if this is not the correct forum?
Thank you!
Best regards
Gjermund Lunder
Developer/DBAhi,
This question suppose to be in framework forum.
you can try:
OA Framework provides the ConcurrentRequest class to call the concurrent program from the page. The submitRequest() method in the ConcurrentRequest class takes 6 parameters and returns request id of the submitted concurrent request:
public int submitRequest(
String ProgramApplication ,
String ProgramName ,
String ProgramDescription ,
String StartTime,
boolean SubRequest,
Vector Parameters ) throws RequestSubmissionException
ProgramApplication -Application Short name of application under which the program is registered.
ProgramName - Concurrent Program Name for which the request has to be submitted
ProgramDescription - Concurrent Program Description
StartTime - Time at which the request has to start running.
SubRequest - Set to TRUE if the request is submitted from another running request and has to be treated as a sub request.
Parameters - Parameters of the concurrent Request
Here is the example for calling a concurrent program from a OA framework page.
import oracle.apps.fnd.cp.request.ConcurrentRequest;
import oracle.apps.fnd.framework.server.OADBTransaction;
public int submitCPRequest(Number headerId) {
try {
OADBTransaction tx = (OADBTransaction)getDBTransaction();
java.sql.Connection pConncection = tx.getJdbcConnection();
ConcurrentRequest cr = new ConcurrentRequest(pConncection);
String applnName = "PO"; //Application that contains the concurrent program
String cpName = "POXXXX"; //Concurrent program name
String cpDesc = "Concurrent Program Description"; // concurrent Program description
// Pass the Arguments using vector
// Here i have added my parameter headerId to the vector and passed the vector to the concurrent program
Vector cpArgs = new Vector();
cpArgs.addElement(headerId.stringValue());
// Calling the Concurrent Program
int requestId = cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs);
tx.commit();
return requestId;
} catch (RequestSubmissionException e) {
OAException oe = new OAException(e.getMessage());
oe.setApplicationModule(this);
throw oe;
I got it from http://prasanna-adf.blogspot.com/2008/11/call-concurrent-program-from-oa.html -
How to pass a HTTP request from a simple java class
Is it possible to pass an HTTP request from a simple java class.if yes how?
Is it possible to pass an HTTP request from a simple
java class.if yes how?If you're talking about creating a HttpRequest object and passing it to a servlet, that would be a red flag to me that your design is flawed. You shouldn't have to do that - the application server (Tomcat, Weblogic, etc) should be the only thing that has to worry about creating that kind of object and passing it to you. -
How to make a http request from a pl/sql procedure(URGENT)
I need to make a http request from a pl/sql procedure, can any one tell me which built-in package and which procedure/function we serve my need?
Thanks in advance.
Ram Prasad.You should use UTL_HTTP package, but before it install the JVM into DB
-
How to run a cygwin.bat from a java program?
Can you please let me know how to run a cygwin.bat file from a java program and to give commands through java program. I have a program to run .exe files, but when I do the same for the cygwin.bat it doesnt work. In task mgr a BASH and a cmd.exe is running. Please help me on this & bit urgent. Thanks in advance!
Can you please let me know how to run a cygwin.bat
file from a java program and to give commands through
java program. I have a program to run .exe files, but
when I do the same for the cygwin.bat it doesnt work.Of course not. .bat files are no native executables. You need to open a shell first, like "cmd /c cygwin.bat ..."
& bit urgent. Thanks in advance!If I had read this earlier I wouldn't have replied. Why exactly is your time worth more than anybody else's? -
How can I pass system commands from a java program? Urgent!
hi,
I have been trying this out since a long time. How do I send system commands to command.com or cmd.exe from a java program and an output of the executed command back to the java application.
If u have any idea, or have any information about the kind os application reply back.
Thanks
Deepa DatarThis is the code which I tried, but it displays only the title of MS-DOS, something like " Microsoft Corp...etc ". But doesn't take any input, and the subprocess(cmd.exe) hangs.
import java.io.*;
public class cmddemo2
public static void main(String arg[])
try
System.out.println("cmd");
Process p=Runtime.getRuntime().exec("cmd.exe");
DataInputStream din=new DataInputStream(p.getInputStream());
DataOutputStream dout=new DataOutputStream(p.getOutputStream());
System.out.println("after streams");
String s;
dout.writeChars("type cmddemo2.java");
while((s=din.readLine())!="\n")
System.out.println(s);
dout.writeChars("dir");
String s1;
while((s1=din.readLine())!="\n")
System.out.println(s1);
System.out.println("over");
catch(Exception e)
{ System.out.println("Exception : "+e); -
How to open my computer window from a java program.....
To open my computer window in win xp is simple from the start menu.
i want to open it from a java program .
any idea to open my computer from a java program or command prompt......http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
import java.util.*;
public class OpenExplorer{
public static void main(String args[]){
new OpenExplorer();
public OpenExplorer(){
try{
String command = "explorer C:";
// or String command = "cmd /c explorer C:";
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(command);
int exitVal = process.waitFor();
System.out.println("Exit Value: " + exitVal);
} catch(Exception e){
e.printStackTrace();
} -
How to read files on server from a java program?
Hello,
I am fairly new to JSP programming. I have an issue with reading files. I am trying to call method of a normal java file from a jsp program. The method I am trying to call does some IO operation on Files. I have the files in the same directory as my class files on server that is in WEB-INF/classes folder. In my java program, I am giving just the file name to open because the files and the classes are in the same directory. But this is not working.
What exactly should I do to read a file from a java program, that is running on the server?
Any help is appreciated.
Thanks,
KrishnaString realFilePath = application.getRealPath("/WEB-INF/myFile.txt");
File fileToOpen = new File(realFilePath);
out.println(fileToOpen.getAbsolutePath() + ": exists? " + fileToOpen.exists());in this case "application" is a reference to the ServletContext.
It is an implicit variable in a JSP. In a servlet:
ServletContext application = getServletConfig().getServletContext(); -
How to list all OS processes from a java program
I want to list/kill all OS processes from a java program, or a part from all processes according to a filter on a name of process.
a similar functionality is ps in Unix or taskkill in Windows XP.
Thanks!Hi,
I was looking for such lib, but finally I decided to accomplish the job with my fingers end ;-). It maigh be helful for u guys:
// is written for x based OSs
private static void killProcess(Process process) {
if (process == null)
return;
process.destroy();
private static void closeProcessStreams(Process process) {
try {
process.getErrorStream().close();
} catch (IOException eyeOhEx) {
private static void listPHPs() {
Process proc = null;
Runtime rt = Runtime.getRuntime();
int exitVal = 0;
try {
proc = rt.exec(" ps -C php"); // here use ur filter. issue "man ps" in linux for more info
catch (Exception ex) {
System.out.println(ex.getMessage());
killProcess(proc);
return;
try {
// process the return list of ur command
InputStream stdReturnStr = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdReturnStr);
BufferedReader br = new BufferedReader(isr);
String line = null;
String returnMsg = "";
boolean firstLine = true;
int[] allPIDs = new int[100]; // finally we have an array of PIDs
int PIDCount = 0;
while ( (line = br.readLine()) != null) {
if (!firstLine){ // the first line is title, ignore it
returnMsg += line + "\n";
String PID = line.trim().split(" ")[0];
System.out.println(PID);
try{
allPIDs[PIDCount] = Integer.parseInt(PID);
PIDCount++;
}catch(Exception ex){
else
firstLine = false;
System.out.println(returnMsg);
catch (Exception t) {
System.out.println(t.getMessage());
killProcess(proc);
return;
try {
exitVal = proc.waitFor();
catch (Exception t) {
System.out.println(t.getMessage());
killProcess(proc);
return;
closeProcessStreams(proc);
Thats it! -
How to send a http-request from abap?
I want to send a xml file through a http-request ,what should i do?
Welcome to SDN
you can use cl_http_client class to do that. search the abap general forum with key word cl_http_client and you will find lot of examples.
Regards
Raja
Maybe you are looking for
-
Recovery on a Satellite A100 (PSAA9) - Deleted partitions and XP Home not Pro
We recently had trouble with our laptop and decided to restore it back to manufacturer settings with the recovery Media CD. My son decided to do it and when he booted up the program he chose the Delete partitions option instead of overwrite. Now it h
-
HT1386 Why Won't my iPhone reflect updates to changes I've made to iTunes playlists on my PC?
When I first got my iPhone, I synced my music and playlists FROM the computer TO the phone. Worked fine. Now every sync makes my PC iTunes match the phone instead of the other way around. The sync only works in one direction & now has deleted some o
-
Reading newly opened command prompt output
I need to use SSH to connect to a server. Rather than downloading a third party SSH API, I would like to use Putty which is already on my computer. The problem is that when using Putty from the command line to connect to a server it opens the connect
-
In MIGO FI Documents post BADI or USEREXIT
hi, In MIGO I wnat to update update Translatn date with Document date befor save, is there any USEREXIT or BADI for that please help. Regards Deepak
-
What is the problem in this podcast?
i'm trying to include this podcast in itunes store http://www.smartoxide.com/itunes/albiol_fr.xml http://www.smartoxide.com/itunes/albiol_ca.xml but itunes don't reported me the problem, and not include in itunes stores, i don't understand! Please he