Mull Sheriff

Greenhorn
+ Follow
since Aug 19, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mull Sheriff

Checked both Manager and Catalina log files: no error messages found.



14 years ago
Hi to all,
I'm trying for the first to time to set up a servlet on tomcat 6.0.20.

I'm getting the error:


type Status report

message /test

description The requested resource (/test) is not available.




Maybe I'm doing it wrong.
That's what I did:

1)I have succerfully compiled the code of the servlet and put the .class file inside the /my-app/WEB-INF/classes/ directory.
2)I have created the web.xml file and copied it into /my-app/WEB-INF/ directory.
3)I have all the libs inside the /my-app/WEB-INF/lib/ directory


Here is the web.xml



Am I missing other steps in order to get a servlet working? Or is the xml code wrong?

thanks in advance for your precious answers.





14 years ago
sorry: double post


14 years ago
JSP

I'm sorry, I didn't mean to say there is no point in writing JSPs. The point in writing JSPs is to generate HTML and that's what you should use them for. Since uploading a file doesn't generate any HTML, using a JSP to do it just complicates things unnecessarily.

So put your file-uploading code into a servlet. When the file uploading is done, forward to a JSP which generates the HTML containing the response to the client.



Thanks again for the answers, I'm going to check out how to build the servlet tomorrow.

No one said that.



My fault. I misunderstood, but thanks to the explanation of Paul Clapham now I get it.

And continuing with your "attitude" is likely to alienate the very people who can help you most. I suggest a change in strategy.



I'm just asking question and I don't want to piss off anyone, but here only Paul Clapham gave me serious answers, other users gave me incomplete answers that did not answered the question of the topic.

Since you said that there is no point in writing JSP pages, why does this section of the forum exist?



This was just a question from a newbie (as I said I am in my first post), I didn't mean to criticize this forum or the users in it.

And yes, those that told you to avoid servlets -- avoid them. They're telling you nonsense.



I know. You are not the only one who told me in this topic.






14 years ago
JSP

A JSP is compiled into a servlet. So you have the choice of putting your code into a servlet, or using a JSP, in which case you end up with a servlet with exactly the same code plus a bunch of JSP scaffolding. Anybody who says using the plain old servlet would "decrease performance" is... no, the forum rule is "Be Nice" so I can't say it.



Thanks for the explanation: I didn't know.

Now I have another question.
According to the fact that "put that thing into a servlet" it's a very common answer here and
Since you said that there is no point in writing JSP pages, why does this section of the forum exist?
14 years ago
JSP

JSPs are compiled to servlets--nothing overly amusing here.

Are you pre-compiling the JSP?



I don't know. I just select the webapp from the tomcat menu and navigate from the web pages I have written.
I guess it's tomcat that handles the compiling.
Like I said, all other .jsp pages are compiled with no errors and they work fine: I have problems just with this one.
14 years ago
JSP

Sure; a JSP is just a servlet.



let me guess. British humor?

By the way, I'm asking that because before starting to learn how a servlet works, I just want to understand why that code does not work. I do value your advice but I'm trying to not to put so much stuff on the fire since is my first web application.

May I have some serious answer now?
14 years ago
JSP

Look upon all they say with suspicion from here on out.



Ok.

Now, about the question: is there a way to do that without servlets?
14 years ago
JSP
My application just has to do this:

1) Query and update a database (not shown in the code)
2) Uploading files on a server.

Nothing more, so I decided to not use servlets due to complication of the usage (deploying....) and
I was told by other more instructed people (more than me) that they decrease performances.

The first part works perfectly.

Is there a way to make the second part working without using servlets?
14 years ago
JSP
JSP.
I don't want anything to do with servlets.
I just call an action=page.jsp?par1=ecc... in a form in the same page.



(Edited to make the post not be three times as wide as my screen - PC)



14 years ago
JSP
hi to all I'm new here and I'm writing because I'm really getting some problems in this code and I don't know how to "translate" those error messages.
This portion of code is supposed to copy a file selected with a input type="file" object into a server (a sub folder of my site in the webapps/mysite/ of the tomcat directory)
PS: I'm quite new to this, and I'm using tomcat 6.0.20 with The Commons FileUpload package.




getting the following errors during the execution:


org.apache.jasper.JasperException: An exception occurred processing JSP page /reg/reg_art_final.jsp at line 109

106:
107:
108:
109: boolean isMultipart = ServletFileUpload.isMultipartContent(request);
110:
111:
112: DiskFileItemFactory factory = new DiskFileItemFactory();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.reg.reg_005fart_005ffinal_jsp._jspService(reg_005fart_005ffinal_jsp.java:230)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
org.apache.commons.fileupload.servlet.ServletFileUpload.isMultipartContent(ServletFileUpload.java:68)
org.apache.jsp.reg.reg_005fart_005ffinal_jsp._jspService(reg_005fart_005ffinal_jsp.java:173)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)





thanks in advance for your precious answers.

14 years ago
JSP