Glad that you got it working. Sorry that you had to struggle through that. I
am surprised that Eclipse's XML editor did not place warning markers about
having multiple definitions of the <servlet-name> tag - it should have done
that provided you had a valid reference to your XSD/DTD within the web.xml
file.

On Sat, Apr 17, 2010 at 8:07 AM, bosun <[email protected]> wrote:

> Thank you for explanation, Chau.  Checking .xsd file is really a good
> practice when having a question about xml schema.
>
>
>
> On Sat, Apr 17, 2010 at 2:47 AM, Chau Huynh <[email protected]> wrote:
>
>> On Sat, Apr 17, 2010 at 8:43 AM, bosun <[email protected]> wrote:
>> Is there a order requirement in <servlet/> element? Or should only one
>> servlet defined in this section?  Anyone know how does invocation make on
>> servlets in section of <servlet/> and <servlet-mapping/> in web.xml ?   Does
>> invocation go through chains of servlet?
>>
>> It's because of incorrect <servlet> and <servlet-mapping> declaration in
>> your old web.xml.
>> Should use each <servlet> to define 1 servlet only (no limit on numer of
>> servlet)
>> The link in web.xml file reference to those syntax
>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd
>> or you can just google "web.xml" for easier explanation.
>>
>>
>> On Sat, Apr 17, 2010 at 8:43 AM, bosun <[email protected]> wrote:
>>
>>> From my observation, <form action="/sign" method="post"> in guestbook.jsp
>>> is expected to trigger doPost method in SignGuestBookServlet but instead, it
>>> invoks doGet method in GuestbookServlet as it's the first servlet defined in
>>> web.xml.  Thus, it causes the error message like HTTP method POST is not
>>> supported by this URL.
>>>
>>> I have been working on this issue for hours and finally I made it worked
>>> but I have to delete the servlet guestbook from entries in <servlet/> and
>>> <servlet-mapping/> in web.xml.  But in tutorial, it didn't mention the
>>> deletion.  It also works if I moved up the servlet sign to the first entry.
>>>   I don't understand why it behaves like this.  It looks to me that doGet
>>> method in GuestbookServet other than doPost method in SignGuestbookServlet
>>> gets invoked immediately after a user clicks Post Greetings, which posts
>>> data in the form.  Is there a order requirement in <servlet/> element? Or
>>> should only one servlet defined in this section?  Anyone know how does
>>> invocation make on servlets in section of <servlet/> and <servlet-mapping/>
>>> in web.xml ?   Does invocation go through chains of servlet?
>>>
>>> After deletion, web.xml now looks like below:
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>> xmlns="http://java.sun.com/xml/ns/javaee";
>>> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
>>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; version="2.5">
>>>  <servlet>
>>> <servlet-name>sign</servlet-name>
>>>  <servlet-class>guestbook.SignGuestbookServlet</servlet-class>
>>> </servlet>
>>>  <servlet-mapping>
>>> <servlet-name>sign</servlet-name>
>>>  <url-pattern>/sign</url-pattern>
>>> </servlet-mapping>
>>>  <welcome-file-list>
>>> <welcome-file>guestbook.jsp</welcome-file>
>>>  </welcome-file-list>
>>> </web-app>
>>>
>>> On Fri, Apr 16, 2010 at 12:42 PM, bosun <[email protected]> wrote:
>>>
>>>> Hi Chau,
>>>> I used the code in the tutorial with a slightly change.  Data is posted
>>>> by POST method in the form so SignGuestbookServlet should use doPost to
>>>> handle it.
>>>> Anothe thing I am confused is that I can't see log message in Eclipse
>>>> console if I added custom message like log.info or system.out.printlin
>>>> alough I givie guestbook.level = INFO in logging.properties.
>>>>
>>>> Code below is SignGuestbookServlet.java:
>>>> import com.google.appengine.api.users.UserService;
>>>> import com.google.appengine.api.users.UserServiceFactory;
>>>> public class SignGuestbookServlet {
>>>>     private static final Logger log =
>>>> Logger.getLogger(SignGuestbookServlet.class.getName());
>>>>
>>>>     public void doPost(HttpServletRequest req, HttpServletResponse resp)
>>>>
>>>>                 throws IOException {
>>>>         UserService userService = UserServiceFactory.getUserService();
>>>>         User user = userService.getCurrentUser();
>>>>
>>>>         String content = req.getParameter("content");
>>>>         if (content == null) {
>>>>             content = "(No greeting)";
>>>>         }
>>>>         if (user != null) {
>>>>             log.info("Greeting posted by user " + user.getNickname() +
>>>> ": " + content);
>>>>         } else {
>>>>             log.info("Greeting posted anonymously: " + content);
>>>>         }
>>>>         resp.sendRedirect("/guestbook.jsp");
>>>>     }
>>>> }
>>>> Code below is guestbook.jsp:
>>>>
>>>> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
>>>> <%@ page import="com.google.appengine.api.users.User" %>
>>>> <%@ page import="com.google.appengine.api.users.UserService" %>
>>>> <%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
>>>> <html>
>>>>   <body>
>>>> <%
>>>>     UserService userService = UserServiceFactory.getUserService();
>>>>     User user = userService.getCurrentUser();
>>>>     if (user != null) {
>>>> %>
>>>> <p>Hi, <%= user.getNickname() %>! (You can
>>>> <a href="<%= userService.createLogoutURL(request.getRequestURI())
>>>> %>">sign out</a>.)</p>
>>>> <%
>>>>     } else {
>>>> %>
>>>> <p>Hello!
>>>> <a href="<%= userService.createLoginURL(request.getRequestURI())
>>>> %>">Sign in</a>
>>>> to include your name with greetings you post.</p>
>>>> <%
>>>>     }
>>>> %>
>>>> Comment Board:
>>>> <form action="/sign" method="post">
>>>>     <div><textarea name="content" rows="3" cols="60"></textarea></div>
>>>>     <div><input type="submit" value="Post Greeting" /></div>
>>>> </form>
>>>>   </body>
>>>> </html>
>>>>
>>>> code below is GuestbookServlet.java:
>>>> package guestbook;
>>>> import java.io.IOException;
>>>> import javax.servlet.http.*;
>>>> import com.google.appengine.api.users.User;
>>>> import com.google.appengine.api.users.UserService;
>>>> import com.google.appengine.api.users.UserServiceFactory;
>>>>
>>>> @SuppressWarnings("serial")
>>>> public class GuestbookServlet extends HttpServlet {
>>>>  public void doGet(HttpServletRequest req, HttpServletResponse resp)
>>>> throws IOException {
>>>>   UserService userService = UserServiceFactory.getUserService();
>>>>         User user = userService.getCurrentUser();
>>>>         //log.info("user name is " + user.getNickname());
>>>>         if (user != null) {
>>>>             resp.setContentType("text/plain");
>>>>             resp.getWriter().println("Hello, " + user.getNickname());
>>>>         } else {
>>>>
>>>> resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
>>>>         }
>>>>   }
>>>> }
>>>>
>>>> On Fri, Apr 16, 2010 at 12:16 PM, Chau Huynh <[email protected]> wrote:
>>>>
>>>>> And next you'll need to post your servlet ;-)
>>>>>
>>>>> Just wonder if you code SignGuestbookServlet servlet yourself - in
>>>>> such a case, you might code doGet() while your JSP posts to the servlet?
>>>>> Error message from your post: "HTTP method POST is not supported by this
>>>>> URL"
>>>>>
>>>>>
>>>>> On Fri, Apr 16, 2010 at 10:59 PM, bosun <[email protected]> wrote:
>>>>>
>>>>>> Hi Rajeev,
>>>>>>
>>>>>> Thank you for helping me troubleshooting this issue.
>>>>>>
>>>>>> Below is web.xml
>>>>>>
>>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>>> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>>>>>> xmlns="http://java.sun.com/xml/ns/javaee";
>>>>>> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";
>>>>>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>>>>>> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; version="2.5">
>>>>>>  <servlet>
>>>>>>   <servlet-name>Guestbook</servlet-name>
>>>>>>   <servlet-class>guestbook.GuestbookServlet</servlet-class>
>>>>>>   <servlet-name>sign</servlet-name>
>>>>>>         <servlet-class>guestbook.SignGuestbookServlet</servlet-class>
>>>>>>  </servlet>
>>>>>>  <servlet-mapping>
>>>>>>   <servlet-name>Guestbook</servlet-name>
>>>>>>   <url-pattern>/guestbook</url-pattern>
>>>>>>         <servlet-name>sign</servlet-name>
>>>>>>         <url-pattern>/sign</url-pattern>
>>>>>>  </servlet-mapping>
>>>>>>  <welcome-file-list>
>>>>>>   <welcome-file>guestbook.jsp</welcome-file>
>>>>>>  </welcome-file-list>
>>>>>> </web-app>
>>>>>>
>>>>>> below is appengine-web.xml
>>>>>>
>>>>>> <?xml version="1.0" encoding="utf-8"?>
>>>>>> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0";>
>>>>>>  <application></application>
>>>>>>  <version>1</version>
>>>>>>
>>>>>>  <!-- Configure java.util.logging -->
>>>>>>  <system-properties>
>>>>>>   <property name="java.util.logging.config.file"
>>>>>> value="WEB-INF/logging.properties"/>
>>>>>>  </system-properties>
>>>>>>
>>>>>> </appengine-web-app>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Apr 16, 2010 at 10:29 AM, Rajeev Dayal <[email protected]>wrote:
>>>>>>
>>>>>>> Can you post the contents of your web.xml file and your
>>>>>>> appengine-web.xml file?
>>>>>>>
>>>>>>>   On Thu, Apr 15, 2010 at 10:21 PM, bosun <[email protected]>wrote:
>>>>>>>
>>>>>>>>  I forgot mention in my post about the version of Eclipse I am
>>>>>>>> using is Galileo.  I downloaded Google plugin for this version.
>>>>>>>>
>>>>>>>> The link to the Tutorial where I am stuck on is:
>>>>>>>> http://code.google.com/intl/en/appengine/docs/java/gettingstarted/usingjsps.html
>>>>>>>>
>>>>>>>> In Eclipse console, all log messages after server restarted are like
>>>>>>>> below:
>>>>>>>>
>>>>>>>>  Apr 16, 2010 2:05:54 AM
>>>>>>>> com.google.apphosting.utils.config.AppEngineWebXmlReader 
>>>>>>>> readAppEngineWebXml
>>>>>>>> INFO: Successfully processed
>>>>>>>> C:\EclipseGalileo\workspace\Guestbook\war\WEB-INF/appengine-web.xml
>>>>>>>> Apr 16, 2010 2:05:54 AM
>>>>>>>> com.google.apphosting.utils.config.AbstractConfigXmlReader 
>>>>>>>> readConfigXml
>>>>>>>> INFO: Successfully processed
>>>>>>>> C:\EclipseGalileo\workspace\Guestbook\war\WEB-INF/web.xml
>>>>>>>> The server is running at http://localhost:8888/
>>>>>>>> Apr 16, 2010 2:07:08 AM
>>>>>>>> com.google.appengine.tools.development.LocalResourceFileServlet doGet
>>>>>>>>  WARNING: No file found for: /favicon.ico
>>>>>>>> Apr 16, 2010 2:07:25 AM
>>>>>>>> com.google.appengine.tools.development.LocalResourceFileServlet doGet
>>>>>>>>  WARNING: No file found for: /favicon.ico
>>>>>>>>
>>>>>>>> Please advise where it goes wrong.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Apr 15, 2010 at 9:57 PM, bobo <[email protected]>wrote:
>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> I run Google App Engine (Java) locally with Eclipse.  Following the
>>>>>>>>> tutorial of Getting Started - Java,  I lean it step by step and my
>>>>>>>>> local server works well until the section Using JSPs.  After adding
>>>>>>>>> SignGuestbookServlet.java and greeting form in guestbook.jsp as
>>>>>>>>> well
>>>>>>>>> as editing web.xml for servlet mapping for sign and /sign,  I
>>>>>>>>> restarted the server. My browser displayed error message
>>>>>>>>> immediately
>>>>>>>>> after I tried to post a greeting message:
>>>>>>>>>
>>>>>>>>> HTTP ERROR 405
>>>>>>>>> Problem accessing /sign. Reason:    HTTP method POST is not
>>>>>>>>> supported
>>>>>>>>> by this URL
>>>>>>>>>
>>>>>>>>> In Eclipse console,  the red error message like:
>>>>>>>>> Apr 16, 2010 1:34:31 AM
>>>>>>>>> com.google.appengine.tools.development.LocalResourceFileServlet
>>>>>>>>> doGet
>>>>>>>>> WARNING: No file found for: /favicon.ico
>>>>>>>>>
>>>>>>>>> I googled this error but seems no one having this problem before.
>>>>>>>>>  I
>>>>>>>>> am stuck on this point and anyone who can shed me a light?
>>>>>>>>>
>>>>>>>>> Thanks!
>>>>>>>>>
>>>>>>>>>
>>>>>>>>   --
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Google App Engine for Java" group.
>>>>>>>> To post to this group, send email to
>>>>>>>> [email protected].
>>>>>>>> To unsubscribe from this group, send email to
>>>>>>>> [email protected]<google-appengine-java%[email protected]>
>>>>>>>> .
>>>>>>>> For more options, visit this group at
>>>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Google App Engine for Java" group.
>>>>>>> To post to this group, send email to
>>>>>>> [email protected].
>>>>>>> To unsubscribe from this group, send email to
>>>>>>> [email protected]<google-appengine-java%[email protected]>
>>>>>>> .
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Google App Engine for Java" group.
>>>>>> To post to this group, send email to
>>>>>> [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected]<google-appengine-java%[email protected]>
>>>>>> .
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Google App Engine for Java" group.
>>>>> To post to this group, send email to
>>>>> [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected]<google-appengine-java%[email protected]>
>>>>> .
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>>>
>>>>
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine for Java" group.
>>> To post to this group, send email to
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-appengine-java%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine-java?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine for Java" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-appengine-java%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine-java?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to