Solved

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

Posted on 2006-11-22
18
1,365 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Running Java Servlet inside Eclipse Luna 6 139
Session migration 1 93
jersey maven project error 7 134
nested if has else if 13 87
Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now