Hey Folks, So this is the rundown:
Essentially, what I want: PL/SQL Procedure call(using UTL_HTTP) --> Java Web Application, Servlet --> opens up a browser window and renders a PDF.
We use the package UTL_HTTP within our PL/SQL Procedure for this, as it has an option to send requests to external urls via the POST method. The only reason we use this package is to ensure our data is passed as POST parameters (apparently, there is no other way to open up external sites directly from PL/SQL procedures while passing parameters through the POST method). There are other means to provide urls directly and pass get parameters as part of the request url string, but this would expose sensitive parameters like username, password, serial id etc.
This http request from the PL/SQL procedure is intercepted by a servlet in our Java Web Application. Our Java Web Application is a Document Management Application and handles all the document management logic.
We managed to reach the servlet and also get a hold of the PDF and put it in the response.
Here's the catch: Since the originating application was a PL/SQL Procedure that sends the HTTP request directly to our Web Application, at no point is a browser window opened. So in our Java servlet class, we get hold of the PDF and write it onto the response. But we need to spawn a browser window to render the pdf. I found this neat site that provides Java Code to open up a browser window directly from a java class. But the problem is that the browser window opens up at the server directly and not on the client.This browser window ought to open up in our client machine from where the http request was issued not at the server.
Any suggestions?
Cheers
If you are using an PL/SQL Web aplication (using APEX or webToolkit) you can send to the browser the blob that you get from the UTL_HTTP call to the servlet
Related
I am building a web application using Spring framework that requires users to make a payment. When the user posts a form, it redirects to Hp's payment website and processes the payments there before returning to my application. This method however leaves my applications vulnerable to security threats and form manipulations.
I now want to post the form to my server, validate users inputs and if necessary post data to hp's web server. I have already written a java code for posting a form from my code and getting the response back into a file from hp's site but am unable to figure out how to redirect the user to the hp website using the java form post. Can someone please help? I am new to Spring so am open to suggestions that would help me accomplish this task either using this method or another way to do so.
Thanks
Obviously you need to perform the redirect on the server side, not on the client side. Redirection is basically returning HTTP 302 with Location header pointing to new location. When browser receives such response it opens the URL in question rather than rendering the response like it is with 200.
If you can receive and validate your form all you have to do is send the redirect back to the browser. I don't know which web framework do you use. In servlets you simply say:
response.sendRedirect("http://www.example.com/payment/...");
In spring-mvc return the following string from your controller as opposed to a view name:
return "redirect:http://www.example.com/payment/...";
Can we read cookies using core-java, that has been written using .NET MVC code? I have not find any help how to read cookies using core java code?
More Background Details -
Actually we have a java desktop application and we are planning to launch that java desktop application using JWS and that is working absolutely fine.
The issue is -- we ask some user related information from user on web page and launch java desktop application using JWS. Now we would like to have that information provided by user on web page in our java application.
We have write that information into cookies and how can we read that information from java code ?
Yes, you can receive cookies that have been set by another application (as long as the path value in the cookie matches). Cookies are part of the HTTP protocol and it does not matter how thay were defined. The client sends them in future requests depending on the URL path.
To access cookies in Java, have a look at getCookies() in HttpServletRequest.
update
The cookies set by your web-application that launches the Java client will have been set in the context of the browser client. Cookies are added to a HTTP response and cached by the client receiving them.
In the case that you describe you cannot access the same server-session from the Java client without trickery.
The solution I would use is to generate a unique ID in the web-app that is passed as argument to the Java client which can in turn request the values needed from the other session using a fetch of a URL using the generated ID as parameter. (This in essence connects the two HTTP sessions as being part of the same user process.)
For instance you could use a HttpURLConnection and a URL like <web-app>/data?id=<ID> to fetch/download the values as XML from your web application.
Core-java? Then try java.net.*:
A cookie is just a header line with "Set-Cookie: " before the URL content.
http://www.hccp.org/java-net-cookie-how-to.html
We have a server written in java, and an application written in phonegap for the android with javascript.
How can we transfer and receive information from the application to the server?
We've tried using DWR to no avail, as the html file is on the android, so we can't call methods on the server.
Is there anyway around it so we can use DWR or another method to contact the server?
Thanks
We transfer and receive information by using AJAX calls and jQuery, and setting the server headers correctly (i.e., setting "Access-Control-Allow-Origin" to "*"). This allows any client to make cross-domain AJAX calls.
I'm developing (with Java) a P2P application. One of the features includes a chat service. When a user sends a message to all of the application users, each user gets the message and updates its chat HTML page.
How can I access, from my Java code, the DOM of this page and change it, without the need to refresh the page in order to see the new message?
Is there any object in Java that can get me this access? For example, can I call a JavaScript function that inserts the new message?
If by from Java you mean applet then:
You can define some javascript functions in your HTML page to return/modify what you want and then call the javascripts from the applet. Look at here.
If by Java you mean Web server then you have to use some AJAX solution, you can look for example at JQuery
What you're really looking for is a technology known as Comet. Comet is Reverse Ajax. It's a technique that uses long-lived HTTP connections to hold a connection open from a client browser to a server so that the server can push updates back to the client browser.
The basic flow is that the server pushes a command back to the browser in the response, and JavaScript parses the response via a callback function, and then the JavaScript updates the DOM, all without reloading the page.
You can learn more about Comet on the CometD Website, and if you're developing on Google App Engine, this blog post on the ChannelAPI will be helpful.
I have written a RIA using flex for the front-end and Java servlet for the back end which actually makes calls to a web-service to do some processing.
The welcome page is a html page which is served from the web-logic 8.1 server that the app is hosted on. The welcome page loads and the flash content loads. Even a 'xml' file containing some configuration properties gets loaded from the server (through URL Request).
Now when I click a button on the page, it would authenticate the user, by sending the data to the servlet.
Here's the problem... The servlet doesn't get invoked and the URL Request (for the servlet with appropriate parameters) returns a 500: Internal Server Error page.
The same code is working perfectly when I deploy it on my local machine using tomcat as a server. And I have also checked umpteen times if the host URL is correct when being deployed on the web-logic server. Even checked the URL when the request is being made, in firefox, using firebug, and all seems to be fine, except that the response is '500: Internal Server Error'.
Please help. Thanks in Advance.
OK, the welcome page loads, and an XML file loads from the webserver, but the servlet can't be invoked.
Is the servlet initialising correctly, and waiting to be called?
Does anything need to be changed in the web.xml file that hasn't been?
Without any more information, it sounds like a misconfigured servlet and/or app server. Check your logs to see if there's any more information there.