Expand my Community achievements bar.

SOLVED

Status\t 201 , Message Created ???

Avatar

Level 2

Hi All,

When I submit a form with two fileds(Login form with username and password), it display me the below message. Do you have any idea about this message. 

I'm using a jsp page with two fields (username and password), when the user clicks on submit button, LoginServlet is called and in here the user details which are submitted in .jsp(login form) are validated. Once the user is validated I'm trying to Log a message, but it is not showing me any message in the Logs. But it shows me the below message when the user clicks on submit. Please post your ideas.

 

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

As a good starting point for getting to know the concepts of resources and rendering I would recommend you to read [1]; it explains the basics and how resources and jsps and servlets can interact. Basically your approach looks good, but the action parameter doesn't look right, as it does not reference a resource. I would expect something like "/content/AemPoc/LoginServlet.example.html" (or whatever the absolute path of the page is, which has the resourcetype "/apps/AemPoc/componentes/PocComponent").

kind regards,
Jörg

 

[1] http://sling.apache.org/documentation/the-sling-engine/resources.html

View solution in original post

4 Replies

Avatar

Level 2

Sorry, I forgot to attach a screenshot for above post for 201 Satus code.

 

Bow, I see Status 200, Message OK, as below.

Content modified /content/LoginServlet

                             
Status
200
Message
OK
Location/content/LoginServlet
Parent Location/content
Path
/content/LoginServlet
Refererhttp://localhost:4502/content/AemPoc0.html
ChangeLog
<pre>modified("/content/LoginServlet/name");<br/>modified("/content/LoginServlet/password");<br/>modified("/content/LoginServlet/Submit");<br/></pre>
 

I created a login form(two fileds) with jsp, and a login servlet for validating the user. Can anyone help me with the folder structure and, what should be the form 'action' path for Loginservlet in .jsp file? Please post your ideas. 

Thanks..

Avatar

Employee Advisor

Hi,

when you see this message, it basically says, that the DefaultPostServlet has created a new for you in the repository. And it says also, that your LoginServlet was actually not called at all. In the OSGI Webconsole you can use the "Recent requests" function to display details about requests; for you the most interesting part is the information, which Servlet was actually called to handle your request. It works for servlets and components, and shows a lot of other useful information about page rendering.

Hope that helps,
Jörg

Avatar

Level 2

Thanks for the quick resonse.

How do I request a servlet from jsp? How do I send the call to serlvet? Any idea? 

Please see my folder structure below for my jsp and servlet.

for jsp page: /apps/AemPoc/components/PocComponent/PocComponent.jsp

action in jsp file is as given:  <form method = "GET" action="LoginServlet.example.html" nctype="multipart/form-data">

LoginServlet : /content/AemPoc/LoginServlet.java , and the component I defined in the LoginServlet.

@Component(immediate = true, metatype = false, label = "LoginServlet")
   @Service
   @Properties(value = {
                    @org.apache.felix.scr.annotations.Property(name = "sling.servlet.methods", value = { "GET" }),
                    @org.apache.felix.scr.annotations.Property(name = "sling.servlet.resourceTypes", value = { "/apps/AemPoc/components/PocComponent" }),
                     @org.apache.felix.scr.annotations.Property(name = "sling.servlet.selectors", value = { "example" }),
                    @org.apache.felix.scr.annotations.Property(name = "sling.servlet.extensions", value = { "html" })

Is my folder structure is correct? and How do I call the LoginServlet from jsp page? I see so many online blogs but I didn't get answer for it.

Thanks,

Avatar

Correct answer by
Employee Advisor

Hi,

As a good starting point for getting to know the concepts of resources and rendering I would recommend you to read [1]; it explains the basics and how resources and jsps and servlets can interact. Basically your approach looks good, but the action parameter doesn't look right, as it does not reference a resource. I would expect something like "/content/AemPoc/LoginServlet.example.html" (or whatever the absolute path of the page is, which has the resourcetype "/apps/AemPoc/componentes/PocComponent").

kind regards,
Jörg

 

[1] http://sling.apache.org/documentation/the-sling-engine/resources.html