Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[wtp-dev] [Dynamic Web Project] JSP - Servlet - web.xml

Hi everyone,

Thank you for reading my post.
Let me explain you what I am trying to do and what my problems are.

I created a new "Dynamic Web Project" using Eclipse.
The "Project Explorer" view shows the following architecture:

(L1 = Level 1, ..., L5 = Level 5)
--------------------------------------------------------------
 1. L1 -- WebProject

 2. L2 -- -- Java Resources
 3. L3 -- -- -- src
 4. L3 -- -- -- servlets
 5. L4 -- -- -- -- (default package)
 6. L5 -- -- -- -- -- ClassUploadFile.java
 7. L3 -- -- -- Libraries
 8. L4 -- -- -- -- Apache Tomcat v6.0 [Apache Tomcat v6.0]
 9. L4 -- -- -- -- EAR Libraries
10. L4 -- -- -- -- JRE System Library [jre6]
11. L4 -- -- -- -- Web App Libraries

12. L2 -- -- JavaScript Support
13. L2 -- -- build
14. L2 -- -- WebContent
15. L3 -- -- -- jsp
16. L4 -- -- -- -- FormUploadFile.jsp
17. L3 -- -- -- META-INF
18. L3 -- -- -- WEB-INF
19. L4 -- -- -- -- lib
20. L4 -- -- -- -- web.xml

21. L1 -- Servers
22. L2 -- -- Tomcat v6.0 Server at localhost-config
--------------------------------------------------------------

As you can see, I have created:
- a folder: "jsp" (line 15.),
- a "Source Folder": "servlets" (line 4.)
- two files: a JSP "FormUploadFile.jsp" (line 16.)
             and a servlet "ClassUploadFile.java" (line 6.).

Roughly,
- the JSP is a HTML form that I want to use
  to choose the file I want to upload,
- the servlet does the uploading job.

My first problem is the following:
I do not really understand the architecture above
and didn't find the reference documentation that
explains it.
I only had a glance at the file:
".settings\org.eclipse.wst.common.component"
which seems to be linked to the problem...
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="WebProject">
        <wb-resource deploy-path="/" source-path="/WebContent"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
        <wb-resource deploy-path="/WEB-INF/classes"
source-path="/servlets"/>
        <property name="context-root" value="WebProject"/>
        <property name="java-output-path"/>
    </wb-module>
</project-modules>
--------------------------------------------------------------------------------

Tiebreaker: what is that "default package" that was created?
What to do with it?

Second problem linked to the first one:
using the Eclipse internal web browser, I type in the URL:
http://localhost:8080/EtiquettesWebProject/jsp/FormUploadFile.jsp
and I properly get my form.
I think it would have been more appropriate to type in the URL:
http://localhost:8080/EtiquettesWebProject/WebContent/jsp/FormUploadFile.jsp
What is the rationale behind it?

Third problem:
I have to customize the "web.xml file".
Here is what is presently looks like:

--------------------------------------------------------------------------------
<?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"; id="WebApp_ID"
version="2.5">

  <display-name>WebProject</display-name>

  <servlet>
    <display-name>ClassUploadFile</display-name>
    <servlet-name>ClassUploadFile</servlet-name>
    <servlet-class>ClassUploadFile</servlet-class>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>ClassUploadFile</servlet-name>
    <url-pattern>/FormUploadFile</url-pattern>
  </servlet-mapping>
</web-app>
--------------------------------------------------------------------------------

Can you tell me if something is wrong whith this
because when I submit the form, the servlet is not 
executed: the form is re-printed on the screen 
and re-initialized.

Here is the "FORM" in the JSP file:
--------------------------------------------------------------------------------
<FORM ENCTYPE="multipart/form-data" ACTION="" METHOD="POST">
  <TABLE STYLE="background-color: lightgreen;" CELLPADDING="5">
    <TR>
      <TD> Choose a file to upload: 
      </TD>
    </TR>
    <TR>
      <TD><INPUT NAME="uploadedfile" TYPE="file" style="width: 227px"/></TD>
    </TR>
    <TR>
      <TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Submit" /></TD>
    </TR>
  </TABLE>
</FORM>
--------------------------------------------------------------------------------

Thanks in advance for your help,
--
Lmhelp
-- 
View this message in context: http://www.nabble.com/-Dynamic-Web-Project--JSP---Servlet---web.xml-tp21951889p21951889.html
Sent from the Eclipse WTP - general mailing list archive at Nabble.com.



Back to the top