-
- Basic Programs
- Servlets Introduction, Tutorial, Architecture
- First Servlet Step-by-Step Explanation – Login Screen Validation
- 7 Steps – Servlets Tomcat Execution
- Deployment Descriptor – web.xml
- Sending dynamically filled HTML form to client
- Sending static HTML form to Client (sendRedirect)
- Read all Form data at a time – getParameterNames() Example -I
- Read all HTML Form Fields at a time with getParameterNames() Example – II
- Read From fields of same name – getParameterValues() Example
- Handling the client request – 3 Styles
- GET vs POST – 12 Differences – Which to prefer?
-
- Retrieving Client Information with request object
- Client’s Browser data with getHeaderNames() and getHeader()
- getRequestURL() method Example
- getRequestURI() Method Example
- Difference between getRequestURL() and getRequestURI()
- getRemoteAddr() Method Example
- getRemoteHost() Method Example
- Difference between getRemoteAddr() and getRemoteHost()
- getQueryString() Method Example
- getContentLength() Method Example
- getServletPath() Method Example
- getMethod() Method Example
- getProtocol() Method Example
- getScheme() Method Example
- Difference between getProtocol() and getScheme()
- getServerPort() Method Example
- isSecure() Method Example
-
- Using response object of HttpServletResponse
- sendRedirect Method Example
- Alternative to PrintWriter – ServletOutputStream Example – When to prefer?
-
- Servlet Communication
- What is ServletConfig interface?
- What is ServletContext interface?
- Difference between ServletConfig and ServletContext
- <init-param> Example with ServletConfig
- <context-param> Example with ServletContext
- Difference between <init-param> and <context-param>
- RequestDispatcher include Example
- RequestDispatcher forward Example
- 16 differences between include and forward
- 20 differences between forward and sendRedirect
- Difference between RequestDispatcher from ServletRequest and ServletContext
-
- Session Tracking
- HTTP Protocol – Stateless and Connectionless
- Session, Session Tracking, Session Management, JSESSIONID
- HTTP Session and HttpSession Methods
- Session Tracking with HttpSession – Hit Count
- Cookie API Methods
- Cookies Simple Shopping Cart Example
- Life Cycle Tutorial with Life Methods
- Life Cycle Example with JDBC
-
- WAR File Creation and Deployment
- WAR File creation in Tomcat
- WAR File creation in Weblogic
- Servlets Made Simple: Learn through Questions/Answers
- 15 Advantages of Servlets over CGI and ASP
- 10 Advantages of Servlets over ASP
- Can we write constructor in Servlet Example?
- What is MIME type in Servlets?
- More on response.setContentType()
- Sending Image to Client
- Feedback Form Example – Using all types of Form fields
- Multiple Submit Buttons in a single HTML Form
- What is SingleThreadModel?
- Auto Page Refresh with Servlets setHeader()
- ServletContext.getResourceAsStream
- MISCELLANEOUS
Dear Sir,
I’m fan of this way2java website. Please let me know is this note available in PDF format as we are staying in hostel. So there is no wifi or net facility.
Thanks
Rashmi
Not available
Hi Nageshwara,
Is it possible to create and use Constructor in servlet?
Yes. You can know yourself. Write one and execute. You will see the output.
Filter is missing in Servlet Tutorial. Pls add this it.
I will do it.
Hello sir,
I wanted to know how we can check format of text entered by user in servlet.
For example for email field the format should be always like “[email protected]”
Check for @ and dot and extra constraints using String, StringBuffer and regular expressions.
Hi sir,
I have an servlet containing database connection code . I want to read the jdbc connection credential from .properties file.And i have save the file in WEB-INF/classes folder.
And in servlet i have the code to read the properties file.i.e
// package custom;
import javax.servlet.*; import javax.servlet.http.*; import java.io.*;
import java.sql.*; import java.util.*;
public class CustomServlet extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
System.out.println(“in service()”);
res.setContentType(“text/plain”);
System.out.println(“at line no 14”);
ObjectInputStream ois = new ObjectInputStream(req.getInputStream( ));
ObjectOutputStream oos = new ObjectOutputStream(res.getOutputStream( ) );
res.setContentType(“application/octet-stream”);
System.out.println(“after application/octet-stream”);// at line 20
try
{
//FileInputStream fis = new FileInputStream(“webapps/ret/WEB-INF/classes/db.properties”);
FileInputStream fis = new FileInputStream(“db.properties”);
Properties p = new Properties();
p.load(fis);
String dr = p.getProperty(“driver”);
String cs = p.getProperty(“url”);
String usr = p.getProperty(“user_name”);
String pwd = p.getProperty(“pwd”);
Class.forName(dr);
Connection con = DriverManager.getConnection(cs,usr,pwd);
……………………………….
………………..
……………………
The control reaches at line no 20 but it will not reach at this line
FileInputStream fis = new FileInputStream(“db.properties”);
………………..
………………….
i don’t know what is wrong with my code.
Please help me
with regards
bikash