| Forums.Sureshkumar.net : A Perfect Place to Share Knowledge Blogs Games Magazines |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Nov 2006
Posts: 20
Thanks: 6 Thanked 0 Times in 0 Posts Thanks: 6
Thanked 0 Times in 0 Posts
Rep Power: 3
|
Servlet Execution !!
Hey Guys,
Kindly tell me how to execute a Servlet i.e. where to save it, where to run it, how and what to deploy, etc,etc,etc,....... Thanx. |
|
|
|
|
|
#2 (permalink) |
|
Junior Member
Join Date: Feb 2007
Age: 26
Posts: 21
Thanks: 0 Thanked 0 Times in 0 Posts Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: Servlet Execution !!
Hi Viskat,
First of all, you need to have a servlet class(Ex: servlEx). Once you are done, follow the below mentioned steps: -> Create a directory(Ex: xyz or abc) ->Create a WEB-INF directory in that directory(in xyz or abc) ->Open WEB-INF directory and create a folder with the name classes ->copy and paste the servlet class(servlEx) in classes directory ->create a web.xml file using notepad or wordpad. In web.xml file, the following tags has to be mentioned: webapp servlet servlet-name /servlet-name(name can be anything of your chioceEx: myservlet) servlet-class /servletclass(servlEx, in our example) /servlet servlet-mapping servlet-name /servlet-name(same name should be givem Ex: myservlet) url-pattern /url-pattern(Ex: /servletexample) /servlet-mapping /web-app Now, copy whole directory(xyz, in our example) to the server. The directory or path varies depending on the web server you are using. If you are using Tomcat, the following procedure is followed: place the xyz directory in $HOME$/webapps(C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps), If you are using any other server, read the documentation provided with the web server. Start the Web Server and Open the Internet Explorer or any web browser(Netscape or Mozilla), and type URL as http://localhost:8080/xyz/servletexample if the server is on localhost and on default port. If it is on network and have different port, relevant ip and port number has to be mentioned. Any questions, kindly let me know Regards, Kris |
|
|
|
|
|
#3 (permalink) |
|
Junior Member
Join Date: Nov 2006
Posts: 20
Thanks: 6 Thanked 0 Times in 0 Posts Thanks: 6
Thanked 0 Times in 0 Posts
Rep Power: 3
|
Displaying Servlet Code !!
Hey I am using WebLogic Server.
When I run the servlet on the browser, it displays the servlet code(class) on the browser page. What to do??????? |
|
|
|
|
|
#6 (permalink) |
|
Junior Member
Join Date: Feb 2007
Age: 26
Posts: 21
Thanks: 0 Thanked 0 Times in 0 Posts Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 2
|
Re: Servlet Execution !!
Have you tried using in other browsers like Internet Explorer..coz there could be a browser specific issue..
|
|
|
|
|
|
#8 (permalink) |
|
Moderator
Join Date: Apr 2006
Location: India
Posts: 636
Thanks: 57 Thanked 78 Times in 63 Posts Thanks: 57
Thanked 78 Times in 63 Posts
Rep Power: 17
|
Re: Servlet Execution !!
Hey Viskat,
No, its not a browser specific issue, whatever the browser or whatever the server version it may be if u have deployed ur web appn correctly it has to work Do one thing man, check ur servlet mapping in the web.xml , i assume your servlet class and servlet mapping are not defined well in web.xml. Your servlet is working the way as it is a HTML page, only HTML pages comes like that since there is no need of defining them in the web.xml . The server is not able to interpret ur servlet, and it is jus taking like an HTML, define the servlet properly in ur web.xml or jus gimme ur servlet name and also attach ur web.xml over here, i'll try to resolve it Let me know your questions Thank You,
__________________
M0h@n |
|
|
|
|
|
#9 (permalink) |
|
Junior Member
Join Date: Nov 2006
Posts: 20
Thanks: 6 Thanked 0 Times in 0 Posts Thanks: 6
Thanked 0 Times in 0 Posts
Rep Power: 3
|
Re: Servlet Execution !!
Hi Mohan,
Thanx for responding. I have executed the doGet() method without using an html file. Its working fine. But am facing problems executing the doPost() method independent of the html file. Below is the web.xml file that i have created and the servletname is "MyServlet" : ----!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" ----web-app display-name--My Web Assignment--/display-name servlet servlet-name--MyServlet--/servlet-name servlet-class--MyServlet--/servlet-class /servlet servlet-mapping servlet-name--MyServlet--/servlet-name url-pattern--/MyServlet/*--/url-pattern /servlet-mapping ----/web-app Kindly tell me whether is this correct or not ?? And also tell me, do we need to edit the web.xml file for each and every servlet?? Thanx. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Leadership in Execution | AjayKumar.Kataram | Inspire yourself & Others - Leaders Zone | 0 | 07-04-07 09:23 PM |
| J2EE - What is the difference between servlet context and servlet config | preethisingh | Java Interview / Technical Questions | 1 | 24-01-07 07:03 PM |
| NJ IndiaInvest Pvt Ltd : Java servlet and PHP | sridhar | FRESHER JOBS | 1 | 19-09-06 06:25 PM |
| CA | vista | Other Queries | 2 | 14-04-06 02:49 AM |
| servlets | naga | JAVA Technologies | 1 | 21-02-06 01:40 PM |