cancel
Showing results for 
Search instead for 
Did you mean: 

how to connect an html page with java-backed webscript

syedwaseemadil
Champ in-the-making
Champ in-the-making
Hi,

i am new in Alfresco. I have developed and properly deploy the SimpleWebScript Example. Now, i want to send some data from an html/jsp web page to my java-backed webscript. I have no idea how to connect html page with the java-backed webscript.
if its just like connecting jsp with servlet then please tell me where should i place my html page in alfresco directory..

If anybody have any resources regarding this problem, please send me the resource i will be very thankful to you

hope i will got solution soon.

Thanks
4 REPLIES 4

kayan
Champ in-the-making
Champ in-the-making
Hi,

The Alfresco webscripts are RESTful and thus you can send the the data with your URL as request parameters from your html/jsp.  Then your javascript should get those parameters as argument object and you can pass the same to your backing java bean.

Hope it will give you some idea.

Thaks
Kayan

syedwaseemadil
Champ in-the-making
Champ in-the-making
Thanks for your reply,

Now i will tell you my problem clearly. i have develope a java class that extends the AbstractWebScript

public class FirstWebScript extends AbstractWebScript
{

   @Override
   public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
   {
      String name = req.getParameter("name");
      String password = req.getParameter("password");
      res.getOutputStream().write((name + "<br>" + password).getBytes());
   }

}
and my webpage is like:

html>
  <body>
    <form action="/java/test/FirstWebScript" method="post" >
       <input type="text" name="name" />
       <input type="text" name="password" />
    </form>
  </body>
</html>
In action i write the path of my java-backed webscript class.(just like we write in jsp to connect to servlet)
Now please tell me two things:
Firstly, that i have done write by writing the path to the webscript class in action. if not then what should i write in the action
and how should i call my java-backed web script

Secondly, whether i should place my webpage in [Alfresco_home]/tomcat/webapps/Alfresco/jsp/    or some where else. My webscript is in [Alfresco_home]/tomcat/webapps/Alfresco/WEB-INF/classes

kayan
Champ in-the-making
Champ in-the-making
Hi,

You need to register your java class on the application context file and then you have to create a webscript descriptor file and put it on the server.  As i said before you can call the webscript as a RESTful URL.  No need to put your jsp/html into alfresco deployment.

Have a look into this wiki, which helps you to create and define bean as well as webscript.

http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples#Declaring_the_Web_Script_.28Spring.29

Also, look into this, it will help you.

http://wiki.alfresco.com/wiki/Web_Scripts#How_Do_I_Create_a_Web_Script.3F

Once you done everything, you can call your script, just simple url on your html/jsp
e.g
http://<Servername>:<Port>/alfresco/service/<URL defined on webscript xml>

Hope this helps.

Thanks
Kayan.

syedwaseemadil
Champ in-the-making
Champ in-the-making
Thank you kayan. I have solved my problem