Solved

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

Posted on 2006-11-22
18
1,388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
Today’s effective marketing is about coming down to the customers’ level and engaging in a whole new way. A text message is one of the most effective and influential ways that you can engage your customers. Here are eight ways that you can utilize t…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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