/src/java/mypackage/myservlet.java
mypackage/Myservlet.java and so on...
William Brogden wrote:
/src/java/mypackage/myservlet.java
mypackage/Myservlet.java and so on...
Servlet container will not compile those classes for you - it is the location of the compiled .class files that is important.
Bill
nsk pavaniI am unable to compile(or create class file) the Servlets. I tried doing through command promt..but i m getting errors!! Please advice!![/quote wrote:
You need to provide more details for futher advice/help ... Your servlet class details like Name , Package (if possible full code itself) , servlet declaration and servlet mapping from your web.xml , if you are getting compilation errors-those errors etc ...
prem pillai wrote:
nsk pavaniI am unable to compile(or create class file) the Servlets. I tried doing through command promt..but i m getting errors!! Please advice!![/quote wrote:
You need to provide more details for futher advice/help ... Your servlet class details like Name , Package (if possible full code itself) , servlet declaration and servlet mapping from your web.xml , if you are getting compilation errors-those errors etc ...
Hi,
My index.jsp page as shown in my first page...
n my Servlet class is in mypackage
package mypackage;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyServlet extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String EmailID= request.getParameter("EMail");
SendMail sm= new SendMail();
sm.sendMail(EmailID);
}
}
I have Send Mail class which send email and working perfectly fine with opther applications...
Now here in NetBeans IDE i am not getting amy compilation errors!
In web.xml,the fields are:
ServletName: MyServlet
Servlet class: mypackage.MyServlet
URL: /MyServlet
Now I know that in action field of form tag, I should give "/MyServlet".
I could run index.jsp page and after submitting my values, it should go to MyServlet but,
I am getting error in my glassfish server : "requested resource() not available". and the url on IE shows : " http://localhost:8080/MyServlet"
And one more thing is, I cannot see .class files of MyServlet n SendMail classes. how do I compile these 2 classes??
So, this is my problem..Please advice me!!
Bear Bibeault wrote:How is the servlet mapped in the deployment descriptor? Is your app the ROOT context? If not, you need to add the context path to the action URL.
Bear Bibeault wrote:Telling us the servlet mapping is not useful. Show us the servlet mapping.
I am unable to compile(or create class file) the Servlets. I tried doing through command promt..but i m getting errors!!
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:Your servlet mapping looks fine... But there is an servlet end tag at the end?
I am unable to compile(or create class file) the Servlets. I tried doing through command promt..but i m getting errors!!
So you don't have servlet classes (.class files) inside the web app (i.e.: <context>/WEB-INF/classes/ dir)? Then first you need to compile them and put in the correct location as I mentioned. What's the issue you have in compiling?
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Vijitha Kumara wrote:Ok then.
Use "./MyServlet" in the action like below
Bear Bibeault wrote:
Vijitha Kumara wrote:Ok then.
Use "./MyServlet" in the action like below
No. Do not.
Using page-relative URLs is a poor practice and will lead to nothing but problems now or in the future. Follow best practices and use server-relative URLs that begin with the context path of the application. Be sure to use ${pageContext.request.contextPath} to look up the context path programatically.
nsk pavani wrote:
Bear Bibeault wrote:
Vijitha Kumara wrote:Ok then.
Use "./MyServlet" in the action like below
No. Do not.
Using page-relative URLs is a poor practice and will lead to nothing but problems now or in the future. Follow best practices and use server-relative URLs that begin with the context path of the application. Be sure to use ${pageContext.request.contextPath} to look up the context path programatically.
I got it!!
Thanks for Advices guys!! They are really helpful!!
![]()