?
Solved

Arranging files under MVC architecture

Posted on 2005-03-27
11
Medium Priority
?
222 Views
Last Modified: 2010-04-01
HI!

I am testing a relatively simple JSP program by using MVC architecture, but I am having “The requested resource (/WEB-INF/hw7/ColorPreferenceMVC4.jsp) is not available.” error.

This is a form that takes input from a user and it is under ~dkim18/hw7/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Color Preference Form4-HW#7</TITLE>

</HEAD>

<BODY>
<CENTER>
<H1> Color Preference Form 4</H1>

<FORM ACTION="/WEB-INF/hw7/ColorPreferenceMVC4.jsp">
   Background: <INPUT TYPE="TEXT" NAME="bgColor"><BR><BR>
   Foreground: <INPUT TYPE="TEXT" NAME="fgColor"><BR><BR>
   <INPUT TYPE="SUBMIT" VALUE="Submit">
</CENTER>
</FORM>
</BODY>
</HTML>
+++++++++++++
This is JSP page that shows output and it is under dkim18\WEB-INF\classes\hw7

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Color Preference MVC 4-HW#7</TITLE>
</HEAD>
<jsp:useBean id="colorBean" type="coreservlets.ColorBean7" />

<BODY BGCOLOR="<jsp:getProperty name="colorBean" property="bgColor" />"
      TEXT="<jsp:getProperty name="colorBean" property="fgColor" />">
<CENTER>
<H1> Color Preference 4 </H1>
Blah, blah, blah.
 </CENTER></BODY></HTML>
+++++++++++++++++++++++++

this is under ~dkim18\WEB-INF\classes\coreservlets/
package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ColorPreferenceServlet extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {

    ColorBean7 colorBean = new ColorBean7();
    request.setAttribute("bgColor", colorBean);
      request.setAttribute("fgColor", colorBean);

    String address = "/WEB-INF/hw7/ColorPreferenceMVC4.jsp";
    RequestDispatcher dispatcher =
      request.getRequestDispatcher(address);
    dispatcher.forward(request, response);
  }
}
++++++
thanks,
0
Comment
Question by:dkim18
[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
  • 4
  • 4
11 Comments
 
LVL 92

Expert Comment

by:objects
ID: 13640971
you cannot put jsp's in WEB-INF, files in this directory cannot be accessed externally.
0
 

Author Comment

by:dkim18
ID: 13640986
This is from core Servlets and JSP 2nd edition.
" If your JSP pages only make sense in the context of servlet-generatd data, place the page under the WEB-INF directory. That way, servlets can forward requests to the pages, but clients cannot access them direclty."
0
 
LVL 92

Expert Comment

by:objects
ID: 13640994
sorry didn't notice you were forwarding to it.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:dkim18
ID: 13641428
so, why am I having this error?
0
 

Author Comment

by:dkim18
ID: 13641558
If I place ColorPreferenceServlets file under ~dkim18/WEB-INF/classes/hw7/ , I get  "javax.servlet.ServletException: bean colorBean not found within scope" error.
0
 

Author Comment

by:dkim18
ID: 13642145
I changed the form that takes input like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Color Preference Form4-HW#7</TITLE>

</HEAD>

<BODY>
<CENTER>
<H1> Color Preference Form 4</H1>

<FORM ACTION="/~dkim18/servlet/hw7.ColorPreferenceServlets">
   Background: <INPUT TYPE="TEXT" NAME="bgColor"><BR><BR>
   Foreground: <INPUT TYPE="TEXT" NAME="fgColor"><BR><BR>
   <INPUT TYPE="SUBMIT" VALUE="Submit">
</CENTER>
</FORM>
</BODY>
</HTML>

Now, I have two different errors depends on content of ColorPreferenceServlets.

0
 
LVL 1

Expert Comment

by:igoruch
ID: 13644425
Hi,
what do you use - TomCat?  -
 Is your servlet mapped in web.xml?




 
0
 
LVL 92

Expert Comment

by:objects
ID: 13647708
> so, why am I having this error?

Because your form's action is your (hidden) jsp.
you can only forward requests to such pages.
0
 
LVL 92

Accepted Solution

by:
objects earned 600 total points
ID: 13647770
> <FORM ACTION="/~dkim18/servlet/hw7.ColorPreferenceServlets">

You should be defining your servlet mapping in your web.xml
0

Featured Post

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!

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 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