开发者

cross domain communication between java application and html application

I have an struts2 based application in开发者_JAVA技巧 one domain and html based website in another domain. I would like to communicate between struts2 applications and html website. Suppose i fill up details(like email id and name) in html form available in html website, on click of submit of form, details should be sent to struts2 based application. Based on the values received from html website, generate one pdf then document should be transferred from struts2 based application to html based website. So now this document is to be displayed to user.


I'm afraid there is some deep confusion here. First, there's no such a thing as "HTML application". HTML is mark-up language for Web pages: it tells to a browser how to display things. You don't write an application with HTML.

So, what you want to do is (roughly):

  • have a Web application (possibly written in Java, since you've tagged your question as such) that produces an HTML form (for email details); such HTML form will contain an action attribute whose value is link pointing back to your Web application
  • when the user access your Web application (at a certain URL), she will see in her browser the HTML form; the user will fill in the details, and click submit
  • when submit button is clicked, the browser will post the content of the form to your Web application using the link in the action attribute of the HTML form
  • your Web application will then receive the form fields as POST parameter, and will be able to process them, possibly build a PDF, and eventually returning it as answer to the user.

That is the whole story from a very high perspective. Behind that there are many details. I recommend that you start with some basic tutorial on how to build (Java) Web application. Good luck!


Step1: Write html form to display input fields(name and email) and place in one domain

Step2: Write action class, inside this write setters and getters code to retrieve name and email then generate one pdf and return forward string to it.

Step3: For the forward string, give one jsp. Inside this jsp write code to display the generated document.

Step4: Place action class and jsp in another domain

Step4: Use one iframe in html form and give src property value as the absolute path of action class mapping name(generatePdf.action) like http://ipaddress:serverportno/contextpath/generatePdf.action?name=xyz&email=xyz@gmail.com

 It hits the specified action class exists in domain2 and gets the output from domain2 and places the output in your html(which contains iframe) form exists in domain1.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜