SlideShare a Scribd company logo
1 of 9
Download to read offline
http://gsbprogramming.blogspot.com
Creating a Servlet
 Create a new Dynamic Web Project.
 Enter the Project Name and click Next button
 You can change the source and classes if you want and click Next button.
http://gsbprogramming.blogspot.com
 You can also change the Context Root (The name by which you accesses the web app). Once
done, click finish.
http://gsbprogramming.blogspot.com
 In Project Explorer, select your project name and Right Click New  Servlet. You can also
select your project and hit ctrl + N to choose servlet option.
http://gsbprogramming.blogspot.com
 Enter Package name (if you want) and class name. You can also change source folder. Once
done click Next.
 Enter the description. You can add/edit the URL mapping. Once the URL pattern matches
this mapping, your servlet will be called using the type of call (get/ post). Below mapping will
corresponds to following URL pattern:
http://localhost:<port>/<context –root>/ServletClass1
http://gsbprogramming.blogspot.com
 Choose the method doGet and click finish.
 Following class will be generated:
 Your servlet will now be visible under Java Resources  src package name in Project
Explorer and also in Navigator
http://gsbprogramming.blogspot.com
 Right click your servlet and choose Run As  Run on Server.
 Following page will be shown:
Here is the URL pattern:
http://localhost:8081/ServletDemo1/ServletClass1
ServletDemo1 is context root.
/ServletClass1 in pattern
For example, if you want to have URL pattern that starts with ServletClass and followed by any
sequence of character, then you can add URL pattern like:
/ServletClass*
* is wildcard here.
http://gsbprogramming.blogspot.com
If you want you can also create multiple URL mappings while creating the servlet:
Each URL mapping should start with Forward Slash (/).
http://gsbprogramming.blogspot.com
So, you can add multiple URL mapping by just separating them with comma:
urlPatterns = { urlMapping1, urlMapping2, urlMapping3 }
Once you right click the servlet class and run it, it will display the context root (/ServletDemo1). To
change the Servlet Context Right click the Project (ServletDemo1) and click Properties. Then in Web
Project Setting change the Context Root.
http://gsbprogramming.blogspot.com
Note: Two servlets cannot have same URL Mapping

More Related Content

What's hot

ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
Sisir Ghosh
 
Simple todo app with meteor
Simple todo app with meteorSimple todo app with meteor
Simple todo app with meteor
Alex Long
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
Sisir Ghosh
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
Vidhi Patel
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5
Sisir Ghosh
 

What's hot (20)

ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
 
Computers & Technology :: Extracting Data from an AJAX-enabled Web Site
Computers & Technology :: Extracting Data from an AJAX-enabled Web SiteComputers & Technology :: Extracting Data from an AJAX-enabled Web Site
Computers & Technology :: Extracting Data from an AJAX-enabled Web Site
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
Simple todo app with meteor
Simple todo app with meteorSimple todo app with meteor
Simple todo app with meteor
 
Anypoint lessons
Anypoint lessonsAnypoint lessons
Anypoint lessons
 
TuleapCon 2018. Tuleap Development circa end of march 2018
TuleapCon 2018. Tuleap Development circa end of march 2018TuleapCon 2018. Tuleap Development circa end of march 2018
TuleapCon 2018. Tuleap Development circa end of march 2018
 
Ajax & ASP.NET 2
Ajax & ASP.NET 2Ajax & ASP.NET 2
Ajax & ASP.NET 2
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
Ajax control tool kit
Ajax control tool kitAjax control tool kit
Ajax control tool kit
 
2310 b 03
2310 b 032310 b 03
2310 b 03
 
METEOR 101
METEOR 101METEOR 101
METEOR 101
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5
 
Deploying and Running in Mule
Deploying and Running in MuleDeploying and Running in Mule
Deploying and Running in Mule
 
Mule esb
Mule esbMule esb
Mule esb
 
Redirect subdomain to webmail
Redirect subdomain to webmailRedirect subdomain to webmail
Redirect subdomain to webmail
 
Github plugin setup in anypointstudio
Github plugin setup in anypointstudioGithub plugin setup in anypointstudio
Github plugin setup in anypointstudio
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
Html5
Html5Html5
Html5
 
Html
HtmlHtml
Html
 
Ember components
Ember componentsEmber components
Ember components
 

Similar to Java Servlet part 3

Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet example
rvpprash
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
Raghu nath
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 
Adding a view
Adding a viewAdding a view
Adding a view
Nhan Do
 

Similar to Java Servlet part 3 (20)

Writing simple web services in java using eclipse editor
Writing simple web services in java using eclipse editorWriting simple web services in java using eclipse editor
Writing simple web services in java using eclipse editor
 
Html servlet example
Html   servlet exampleHtml   servlet example
Html servlet example
 
Jsp and Servlets
Jsp and ServletsJsp and Servlets
Jsp and Servlets
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Untangling the web9
Untangling the web9Untangling the web9
Untangling the web9
 
Java script Basic
Java script BasicJava script Basic
Java script Basic
 
Jsp tutorial
Jsp tutorialJsp tutorial
Jsp tutorial
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
 
Understanding JSP -Servlets
Understanding JSP -ServletsUnderstanding JSP -Servlets
Understanding JSP -Servlets
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
Unit5 servlets
Unit5 servletsUnit5 servlets
Unit5 servlets
 
code-camp-meteor
code-camp-meteorcode-camp-meteor
code-camp-meteor
 
Useful Rails Plugins
Useful Rails PluginsUseful Rails Plugins
Useful Rails Plugins
 
servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0servlet 2.5 & JSP 2.0
servlet 2.5 & JSP 2.0
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishGrails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
 
How to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScriptHow to Build ToDo App with Vue 3 + TypeScript
How to Build ToDo App with Vue 3 + TypeScript
 
JAVA SERVER PAGES
JAVA SERVER PAGESJAVA SERVER PAGES
JAVA SERVER PAGES
 
Example Cosmos SDK Application Tutorial
Example Cosmos SDK Application TutorialExample Cosmos SDK Application Tutorial
Example Cosmos SDK Application Tutorial
 
Java Servlets & JSP
Java Servlets & JSPJava Servlets & JSP
Java Servlets & JSP
 
Adding a view
Adding a viewAdding a view
Adding a view
 

More from Gurpreet singh

More from Gurpreet singh (20)

Introduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP ReportingIntroduction to Oracle Fusion BIP Reporting
Introduction to Oracle Fusion BIP Reporting
 
Why Messaging system?
Why Messaging system?Why Messaging system?
Why Messaging system?
 
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...Understanding Flex Fields with  Accounting Flexfields(Chart of Accounts) in O...
Understanding Flex Fields with Accounting Flexfields(Chart of Accounts) in O...
 
Oracle Application Developmenr Framework
Oracle Application Developmenr FrameworkOracle Application Developmenr Framework
Oracle Application Developmenr Framework
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
Oracle SQL Part1
Oracle SQL Part1Oracle SQL Part1
Oracle SQL Part1
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
IO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxingIO Streams, Serialization, de-serialization, autoboxing
IO Streams, Serialization, de-serialization, autoboxing
 
Creating business group in oracle apps
Creating business group in oracle appsCreating business group in oracle apps
Creating business group in oracle apps
 
Defing locations in Oracle Apps
Defing locations in Oracle AppsDefing locations in Oracle Apps
Defing locations in Oracle Apps
 
Assigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYSTAssigning role AME_BUS_ANALYST
Assigning role AME_BUS_ANALYST
 
PL/SQL Part 5
PL/SQL Part 5PL/SQL Part 5
PL/SQL Part 5
 
PL/SQL Part 3
PL/SQL Part 3PL/SQL Part 3
PL/SQL Part 3
 
PL/SQL Part 2
PL/SQL Part 2PL/SQL Part 2
PL/SQL Part 2
 
PL/SQL Part 1
PL/SQL Part 1PL/SQL Part 1
PL/SQL Part 1
 
Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)Introduction to Data Flow Diagram (DFD)
Introduction to Data Flow Diagram (DFD)
 
Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)Ingenium test(Exam Management System) Project Presentation (Full)
Ingenium test(Exam Management System) Project Presentation (Full)
 
Computer Graphics Notes
Computer Graphics NotesComputer Graphics Notes
Computer Graphics Notes
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Java Servlet part 3

  • 1. http://gsbprogramming.blogspot.com Creating a Servlet  Create a new Dynamic Web Project.  Enter the Project Name and click Next button  You can change the source and classes if you want and click Next button.
  • 2. http://gsbprogramming.blogspot.com  You can also change the Context Root (The name by which you accesses the web app). Once done, click finish.
  • 3. http://gsbprogramming.blogspot.com  In Project Explorer, select your project name and Right Click New  Servlet. You can also select your project and hit ctrl + N to choose servlet option.
  • 4. http://gsbprogramming.blogspot.com  Enter Package name (if you want) and class name. You can also change source folder. Once done click Next.  Enter the description. You can add/edit the URL mapping. Once the URL pattern matches this mapping, your servlet will be called using the type of call (get/ post). Below mapping will corresponds to following URL pattern: http://localhost:<port>/<context –root>/ServletClass1
  • 5. http://gsbprogramming.blogspot.com  Choose the method doGet and click finish.  Following class will be generated:  Your servlet will now be visible under Java Resources  src package name in Project Explorer and also in Navigator
  • 6. http://gsbprogramming.blogspot.com  Right click your servlet and choose Run As  Run on Server.  Following page will be shown: Here is the URL pattern: http://localhost:8081/ServletDemo1/ServletClass1 ServletDemo1 is context root. /ServletClass1 in pattern For example, if you want to have URL pattern that starts with ServletClass and followed by any sequence of character, then you can add URL pattern like: /ServletClass* * is wildcard here.
  • 7. http://gsbprogramming.blogspot.com If you want you can also create multiple URL mappings while creating the servlet: Each URL mapping should start with Forward Slash (/).
  • 8. http://gsbprogramming.blogspot.com So, you can add multiple URL mapping by just separating them with comma: urlPatterns = { urlMapping1, urlMapping2, urlMapping3 } Once you right click the servlet class and run it, it will display the context root (/ServletDemo1). To change the Servlet Context Right click the Project (ServletDemo1) and click Properties. Then in Web Project Setting change the Context Root.