We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

Dear all, 

I have received lot of msgs and private chat messages that students are facing problem in compiling java servlet.

The errors might be as below if you compile a servlet i.e. HelloWorldServlet

D:\java umt>javac HelloWorldServlet.java
HelloWorldServlet.java:4: error: package javax.servlet does not exist
import javax.servlet.*;
^
HelloWorldServlet.java:5: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloWorldServlet.java:6: error: cannot find symbol
public class HelloWorldServlet extends HttpServlet{
^
symbol: class HttpServlet
HelloWorldServlet.java:10: error: cannot find symbol
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
^
symbol: class HttpServletRequest
location: class HelloWorldServlet
HelloWorldServlet.java:10: error: cannot find symbol
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
^
symbol: class HttpServletResponse
location: class HelloWorldServlet
HelloWorldServlet.java:10: error: cannot find symbol
public void doGet(HttpServletRequest request,HttpServletResponse response) throws

symbol: class ServletException
location: class HelloWorldServlet
6 errors

 The reason behind is that it need that library (.jar) file which contains all servlet related dependencies.

TO fix this error first you need to know the location of your  tomcat for example in my case it is "d:\tomcat8"

To Compile your Servlet with notepad and command line u need to run below command javac -classpath D:\tomcat8\lib\servlet-api.jar HelloWorldServlet.java

if your tomcat is installed on D:\apache-tomcat-6.0.44

then u will compile ur servlet like

javac -classpath D:\apache-tomcat-6.0.44\lib\servlet-api.jar HelloWorldServlet.java  

in command above we are just providing compiler that servlet-api.jar file is located at particular location.

Welcome for your questions.

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 622

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Replies to This Discussion

HelloWorldServlet.java file ko pehle konci directory mein rakhna hai??

You can place anywhere to compile it. it will generate a HelloWorldServlet.class file. then u need to place this .class file into
/WEB-INF/classes/HelloWorldServlet.class

Main ne assignment complete ker li hai.. lakin jab main values enter ker k Solve Equation ka button press kerta hoon to error aata hai... Please see the images and let me know the problem... Thanks

This error is due to "you are using form method GET and in servlet you are using doPost method or vice versa

3 ways to solve it

1. write your code in doGet Method and use form method as GET

2. write you code in doPost method and use form metho as POST

3. create a private function for example processRequest with same signature as doGet or doPost and then call this method in both doGet and doPost method. see example below

public class HelloWorldServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("Hello");
}


protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request,response);
}

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
processRequest(request,response);
}

}

Thanks a lot for you help... Resolved this issue... 

you welcome

Great work by SK(MS-SE) ..........

plz tell me how can i resolved this?

RSS

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.