Skip navigation
adobe4440
Currently Being Moderated

need to call servlet  from jsp how

Dec 12, 2012 6:37 AM

generally we specify in action attribute 

 

in cq how to specify the servlet path

 

what should be the folder structure plz explain with an example

 
Replies
  • Currently Being Moderated
    Dec 12, 2012 9:06 AM   in reply to adobe4440

    http://sling.apache.org/site/servlets.html

     

    http://wemcode.wemblog.com/create-servlet

     

    And from JSP just call it using servlet path.

     

    Yogesh

    www.wemblog.com

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2013 4:06 AM   in reply to Yogesh Upadhyay

    how to call  can u please tell me need to put the full path of  the sling servlet or to put only the servlet name

     
    |
    Mark as:
  • kasq
    130 posts
    Dec 1, 2011
    Currently Being Moderated
    Jan 24, 2013 4:18 AM   in reply to ddigal

    hi,

     

    first of all try to make this kind annotation in your sling servlet:

     

    @Component(immediate = true, metatype = false, label = "ExampleServlet")

    @Service

    @Properties(value = {

          @org.apache.felix.scr.annotations.Property(name = "sling.servlet.methods", value = { "POST [or GET]" }),

          @org.apache.felix.scr.annotations.Property(name = "sling.servlet.resourceTypes", value = { "sling/servlet/default" }),

          @org.apache.felix.scr.annotations.Property(name = "sling.servlet.selectors", value = { "example" }),

          @org.apache.felix.scr.annotations.Property(name = "sling.servlet.extensions", value = { "html" })

       })

     

    ......CODE FOR A SERVLET .............

     

    and then use in your jsp a form like this:

     

    <form id="submitForm" method="post [or get]" action="test.example.html">

            <input type="submit" value="Submit"/>

      </form>

     

    Generally speaking your sling servlet is recognize by the selector and extension which is defined in the annotations in the Servlet java file and then using it in the action atribute Sling know which servlet must be called.

     

    Of course before you start testing you servlet, the bundle with your servlet must be installed and active in the Apache Felix Console and also your ExampleServlet must be visible in the bundle in the Services list.

     

    Regards,

    kasq

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 24, 2013 4:32 AM   in reply to kasq

    thanks kasq for giving me the fully knowledge on slingservlet

     

     

     

    Regards

    ddigal

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 4, 2013 11:02 PM   in reply to kasq

    when i put this notation  its showing type property is ambiguous.what to do pls tell dude

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 28, 2013 11:10 AM   in reply to adobe4440
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points