Solved

JSP + Servlet in which can't find the page.

Posted on 2006-11-22
18
1,375 Views
Last Modified: 2007-12-19
I have a JSP page and the servlet.


<form name="wizard" method="POST" action="/ServiceRequest" onsubmit="return checkData()">


srServlet
==
public class ServiceRequestServlet extends HttpServlet {

      private static final Log log = LogFactory.getLog(ServiceRequestServlet.class);
      protected void doGet(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
            log.debug("doGet - Start");
            doWork(request,response);
      }

      protected void doPost(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException, IOException {
            log.debug("doPost - Start");
            doWork(request,response);
      }

      public void doWork(
            HttpServletRequest request,
            HttpServletResponse response)
            throws ServletException {

            log.debug("doWork - Start");
            ServiceRequestProcessorLocal order = initializeController();
            handleRequest(request, response, order);
            viewAllBookings(request, order);
            HttpSession session = request.getSession(true);
            RequestDispatcher dispatcher = request.getRequestDispatcher("/customer/createSR_action");
            try {
                  dispatcher.forward(request, response);
            } catch (IOException e) {
                  e.printStackTrace();
                  throw new ServletException(e.getMessage());
            }
      }
==========================================================

web.xml


    <servlet-mapping>
        <servlet-name>ServiceRequestServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
 
    <servlet-mapping>
        <servlet-name>createSR_action.jsp</servlet-name>
        <url-pattern>/customer</url-pattern>
    </servlet-mapping>


=================================================================
please advise why it can't find the createSR_action.jsp page
0
Comment
Question by:LeanMoreTryMore
  • 10
  • 7
18 Comments
 
LVL 16

Expert Comment

by:suprapto45
ID: 18000309
Hi,

>>"RequestDispatcher dispatcher = request.getRequestDispatcher("/customer/createSR_action");"
You are not calling createSR_action.jsp but instead you are calling createSR_action. Is it a Servlet again?

>>"    <servlet-mapping>
        <servlet-name>createSR_action.jsp</servlet-name>
        <url-pattern>/customer</url-pattern>
    </servlet-mapping>"
I do not think that it is necessary. Why do you want to map a JSP as a servlet?

David
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000330
yes.
the servlet is mainly used to call the ejb application to be used to insert and send email, then it redirect to a jsp page as a confirmation page.

so what do u suggest?

please advise.

first time to build the web page using jsp.
I used to build the bean and backend applicaiton.

so i dont know all these

0
 

Author Comment

by:LeanMoreTryMore
ID: 18000339
how do i know the servlet is called?
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 16

Expert Comment

by:suprapto45
ID: 18000350
Try to change

RequestDispatcher dispatcher = request.getRequestDispatcher("/customer/createSR_action");
into
RequestDispatcher dispatcher = request.getRequestDispatcher("/customer/createSR_action.jsp");

assuming that after everything is executed, you are going to createSR_action.jsp.

Then you can remove those entries that I mentioned before in your web.xml.

David
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000508
Not working dont know why
I guess in JSP page, where the Submit button is clicked, it calls

   <form name="wizard" method="POST" action="/ServiceRequest" onsubmit="return checkData()">
         <input type="hidden" name="appAction" value="<%=Constants.ACTION_SAVE%>"/>

The URL on web browser shown
http://myc029736:50000/ServiceRequest


The requested resource does not exist.
  Details:   Go to main page of this application!
 
 
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000519
make it easy the servlet outputs the information in which shows the confirmation page.

HOw can i do that?
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000523
I dont think the ServiceRequestServlet.jar get called...
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18000536
Okay,

>>"   <form name="wizard" method="POST" action="/ServiceRequest" onsubmit="return checkData()">
        <input type="hidden" name="appAction" value="<%=Constants.ACTION_SAVE%>"/>"

Do you have the submit button as

   <form name="wizard" method="POST" action="/ServiceRequest" onsubmit="return checkData()">
        <input type="hidden" name="appAction" value="<%=Constants.ACTION_SAVE%>"/>
        <input type="submit" name="submit" value="submit" />

Then try to change your web.xml as

    <servlet-mapping>
        <servlet-name>ServiceRequestServlet</servlet-name>
        <url-pattern>/ServiceRequest</url-pattern>
    </servlet-mapping>

And do you have something like below in your web.xml?

    <servlet>
        <servlet-name>ServiceRequestServlet</servlet-name>
        <servlet-class>whatever.package.here</servlet-class>
    </servlet>
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000579
Your guess is exactly right.

In my JSP page, it does have a Submit button like below


   <form name="wizard" method="POST" action="/ServiceRequest" onsubmit="return checkData()">
.
.
                    <td align="center" bgcolor="DEE3E9">
                        <input type="submit" name="srAdd" value="Submit" >
                    </td>

====================================================================
In my web.xml

For servlet mapping
-----------------------
      <servlet-mapping>
            <servlet-name>ServiceRequestServlet</servlet-name>
            <url-pattern>/</url-pattern>
      </servlet-mapping>


For servlet tag

      <servlet>
            <servlet-name>ServiceRequestServlet</servlet-name>
            <servlet-class>com.ieg.servicerequest.servlet.ServiceRequestServlet</servlet-class>
      </servlet>

=====================================================
so what should i do based on the above setting in web.xml
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18000582
Try to change your web.xml into

     <servlet-mapping>
          <servlet-name>ServiceRequestServlet</servlet-name>
          <url-pattern>/ServiceRequest</url-pattern>
     </servlet-mapping>

and try again
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000587
I change to:

      <servlet-mapping>
            <servlet-name>ServiceRequestServlet</servlet-name>
            <url-pattern>/ServiceRequest</url-pattern>
      </servlet-mapping>

and run, i got different error

You are not authorized to view the content of the requested directory.
  Details:   Directory listing is not allowed on this server.
 
 

NOtes: After i deploy to EAR and modify the application.xml to

<application>
      <display-name>ServiceRequestApplication</display-name>
      <description>Modules for online service request</description>
      <module>
            <ejb>SRejb.jar</ejb>
      </module>
      <module>
            <web>
                  <web-uri>SRweb.war</web-uri>
                  <context-root>/ServiceRequest</context-root>
            </web>
      </module>
</application>

**** THE WEB context-root is /ServiceRequest  ...
is it crashed?
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000605
so i changed to

      <servlet>
            <servlet-name>ServiceRequestServlet</servlet-name>
            <servlet-class>com.ieg.au.servicerequest.servlet.ServiceRequestServlet</servlet-class>
      </servlet>
      <servlet-mapping>
            <servlet-name>ServiceRequestServlet</servlet-name>
            <url-pattern>/ServiceRequest/servlet</url-pattern>
      </servlet-mapping>

in Jsp

<form name="wizard" method="POST" action="/ServiceRequest/servlet" onsubmit="return checkData()">


but i got the following error

The request cannot be processed.
  Details:   com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [/ServiceRequest/servlet] not found.
 
 
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18000610
Hi,

I believe that this is related to your SAP NetWeaver so I am not really sure.

Look at this URL.
https://www.sdn.sap.com/irj/sdn/message?messageID=2656875
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 18000619
>>"The request cannot be processed.
  Details:   com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [/ServiceRequest/servlet] not found."

For this error, try to restart your server and try again. Sometimes, it is not deploying successfully.
0
 
LVL 27

Assisted Solution

by:rrz
rrz earned 50 total points
ID: 18000666
>**** THE WEB context-root is /ServiceRequest  ...  
><url-pattern>/ServiceRequest/servlet</url-pattern>
In this case, instead of  using  
> <form name="wizard" method="POST" action="/ServiceRequest/servlet"
you should use  
><form name="wizard" method="POST" action="ServiceRequest/servlet"
or
<form name="wizard" method="POST" action="/ServiceRequest/ServiceRequest/servlet"
0
 

Author Comment

by:LeanMoreTryMore
ID: 18000720
** i found the reason why it can't find the page

The url shown

http://myc029736:50000/ServiceRequest/customer/ServiceRequest/servlet

instead of
http://myc029736:50000/ServiceRequest/servlet


When I manually type the URL from the web browser http://myc029736:50000/ServiceRequest/servlet, the servlet has been called the page.

But i dont know how to fix

In web.xml, the servlet tag for the jsp page is


That's why when the createSR.jsp is called, the URL is http://myc029736:50000/ServiceRequest/customer/createSR.jsp

    <servlet>
        <servlet-name>createSR.jsp</servlet-name>
        <jsp-file>/customer/createSR.jsp</jsp-file>
    </servlet>
0
 
LVL 16

Accepted Solution

by:
suprapto45 earned 450 total points
ID: 18000761
Hi,

I think that
<form name="wizard" method="POST" action="/ServiceRequest/servlet">
shoud work fine.

And
>>"    <servlet>
        <servlet-name>createSR.jsp</servlet-name>
        <jsp-file>/customer/createSR.jsp</jsp-file>
    </servlet>"
You do not need this. You can remove it from your web.xml.

David
0
 

Author Comment

by:LeanMoreTryMore
ID: 18004967
very thanks for all your help.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java.util.concurrent.locks in java 3 191
constructor overloading 2 83
java operators 3 114
thymeleaf natural templating vs JSP 2 98
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question