Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Get Information About Server in Servlet
WhatsApp
SHUBHAM SHARMA
5y
3.6
k
0
0
25
Blog
The Body of Index.jsp page
< form action = servlet / First_Servlet method =
"post"
> < br > First_Name < input type =
"text"
name =
"user_name"
> < input type =
"submit"
value =
"Submit"
> < /form><br></body >
First_Servlet
import
javax.servlet.*;
import
java.util.Enumeration;
import
java.io.IOException;
public
class
First_Servlet
implements
Servlet {
public
void
destroy() {}
public
ServletConfig getServletConfig() {
return
null
;
}
public
String getServletInfo() {
return
null
;
}
public
void
init(ServletConfig config)
throws
ServletException {}
public
void
service(ServletRequest req, ServletResponse res)
throws
ServletException, IOException {
System.out.println(
"server_port_Number++++++++++++++++++++++++++++++++++++++++++++++++++++"
+ req.getServerPort());
System.out.println(
"Server_Name"
+ req.getServerName());
System.out.println(
"Protocol"
+ req.getProtocol());
System.out.println(
"charcter encoding"
+ req.getCharacterEncoding());
Enumeration parameter = req.getParameterNames();
while
(parameter.hasMoreElements()) {
String parameter_name = (String) parameter.nextElement();
System.out.println(
"parameter_name"
+ parameter_name);
System.out.println(
"parameter_value"
+ req.getParameter(parameter_name));
}
Enumeration attributes = req.getAttributeNames();
while
(attributes.hasMoreElements()) {
String attribute = (String) attributes.nextElement();
System.out.println(
"parameter_name"
+ attribute);
System.out.println(
"parameter_value"
+ req.getParameter(attribute));
}
}
Get information About Server in servlet
People also reading
Membership not found