12 must know Java web basics interview questions and answers
12 must know Java web basics interview questions and answers
Home › Quick Prep Java Interview › 150+ Java Architect FAQs 📌 › Architecture - How to › 01: 12 Web basics
every Java web developer must know – Part 1
Posted on August 22, 2014 100+ Java code quality Q&As
150+ Java coding Q&As
Q1. HTTP is a stateless protocol, so how do you maintain state?
How do you store user data between requests?
A1. This is a commonly asked interview question. The “http protocol
is a stateless request/response based protocol”. You can retain the 300+ Big Data Interview
state information between different page requests as follows: Q&As - Quick Prep FAQs
HTTP Session. A session identifies the requests that originate from 300+ Big Data Interview
the same browser during the period of conversation. All the servlets FAQs 📌
can share the same session. The JSESSIONID is generated by the 250+ Scala Interview FAQs
server and can be passed to client through cookies, URL re-writing (if 250+ Python interview
cookies are turned off) or built-in SSL mechanism. Care should be FAQs 📌
1 http://localhost:8080/myWebCtxt/purchase.do;jsessionid=4FB6131
1 response.encodeURL(givenURL)
1 response.encodeRedirectURL(givenURL)
Hidden Fields on the pages can maintain state and they are not
visible on the browser. The server treats both hidden and non-hidden
fields the same way.
1 Http://MyServer:8080/MyServlet?Firstname=Peter&Lastname=Smith
– If you type the URL of a website into your browser, your browser
sends the request to the Web server. When the browser does this it
looks on your machine for a cookie file that URL has set. If it finds it,
your browser will send all of the name-value pairs along with the
URL. If it does not find a cookie file, it sends no cookie data.
– The URL’s Web server receives the cookie data and requests for a
page. If name-value pairs are received, the server can use them. If no
name-value pairs are received, the server can create a new ID and
then sends name-value pairs to your machine in the header for the
Web page it sends. Your machine stores the name value pairs on
your hard disk.
Cookies can be used to determine how many visitors visit your site.
It can also determine how many are new versus repeated visitors.
The way it does this is by using a database. The first time a visitor
arrives; the site creates a new ID in the database and sends the ID as
a cookie. The next time the same user comes back, the site can
increment a counter associated with that ID in the database and
know how many times that visitor returns. The sites can also store
user preferences so that site can look different for each visitor.
sessions or else the whole system breaks down. The answer to this
problem is using sticky sessions which force the load balancer to
send traffic for a given user to the same server every time. The LB is
hardly balancing load if it can’t decide who gets the traffic. There are
other more complicated methods for sharing sessions across
multiple servers via true clustering, but getting this right is more
complicated and time consuming.
https://www.java-success.com/web-basics-interview-questions-and-answers/ 4/9
06/12/2024, 19:52 12 must know Java web basics interview questions and answers
URL
URLs reveal the identity of the particular host with which we want to
communicate, but the action that should be performed on the host is
specified via HTTP verbs. A client can perform a number of actions
like GET (fetch an existing resource), POST (create a new resource),
PUT (update an existing resource,), DELETE (delete an existing
resource), etc.
With URLs and verbs, the client can initiate requests to the server. In
return, the server responds with status codes and message
payloads. The status code is important and tells the client how to
interpret the server response. The most common code is 200 OK,
which tells the client that the request was successfully processed.
3xx: like 301, 302, etc indicate redirection, which requires the client to
take additional action. The most common use-case is to jump to a
different URL in order to fetch the resource.
4xx: like 404. etc means Client Error. These codes are used when the
server thinks that the client is at fault, either by requesting an invalid
resource or making a bad request.
5xx: like 501, 503, etc means Server Error. This class of codes are
used to indicate a server failure while processing the request. The
most commonly used error code is 500 Internal Server Error.
Forward
Redirect
Post-back
— The HTTP verb POST is used to send data to the server in the
body, with XML, JSON, or form fields.
— The term “back” really means that you retrieved the page initially
with a GET verb to show user the <form> elements, and at the end
you’re sending data back. So, a PostBack is a POST request for a
page that is not the first request.
JSON, plain text or HTML. So, the “X”, AJAX was coined to send and
receive XML messages asynchrously, but it can send/recive JSON,
plain text, etc.
The modern Rich Internet Applications (RIA) use the design concept
of “single page web design“, where a single rich page makes AJAX
based service calls to render different sections of a page instead of
the traditional approach of loading a new page of each user action.
The “single page web design” can make use of client side and server
side technologies.
Q07 to Q12: 12 Web basics every Java web developer must know –
Part 2.
‹ 05: 9 Java multithreading Q&As on concepts like blocking, sequencing, preempting, time slicing
Arulkumaran Kumaraswamipillai
Mechanical Engineer to self-taught Java engineer in 1999. Contracting since 2002 as a Java Engineer &
Architect and since 2016 as a Big Data Engineer & Architect. Preparation & key know-hows empowered me
to attend 150+ job interviews, choose from 130+ job offers & negotiate better contract rates. Author of the
book "Java/J2EE job interview companion", which sold 35K+ copies & superseded by this site with 3.5K+
registered users Amazon.com profile | Reviews | LinkedIn | LinkedIn Group | YouTube Email: java-
interview@hotmail.com
https://www.java-success.com/web-basics-interview-questions-and-answers/ 7/9
06/12/2024, 19:52 12 must know Java web basics interview questions and answers
"You are paid to read & write lots of code & solve business problems in a
collaborative environment"
100+ Free Java Interview FAQs
100+ Free Big Data Interview FAQs
Don't be overwhelmed by the number of Q&As. Job interviews are not technical contests to see who gets most number of questions right.
Nobody knows everything. The Clarity of the answers you give with real-life examples will go a long way in getting you multiple job offers.
It pays to brush-up & choose from 2-6 job offers. Experienced interviewers can easily judge your real experience from a few open-ended
questions & the answers you provide.
1. Feeling stagnated?
2. How to earn more?
3. Freelancing Vs contracting?
4. Self-taught professional?
5. Job Interview Tips
6. Resume Writing Tips
300+ Big Data Interview Q&As with code, scenarios & FAQs
100+ SQL Interview Q&As 01. 50+ SQL scenarios based interview Q&As – What is wrong with this SQL code? 02.…
(2,429)
00: Top 50+ Core Java interview questions & answers for 1 to 3 years experience
Top 50 core Java interview questions covering core Java concepts with diagrams, code, examples, and scenarios. If you don't get…
(1,977)
Java 8 String streams and finding the first non repeated character with functional programming
Q1.Find the first non repeated character in a given string input using Java 8 or later? A1.Extends Find the first…
(1,676)
Membership Levels
Membership prices listed below are in Australian Dollars (A$). If you purchase in other currencies like Indian rupees, the equivalent…
(718)
https://www.java-success.com/web-basics-interview-questions-and-answers/ 8/9
06/12/2024, 19:52 12 must know Java web basics interview questions and answers
0: 50+ SQL scenarios based interview Q&As – What is wrong with this SQL code?
This extends 18+ SQL best practices & optimisation interview Q&As. You can practice these SQLs by setting up the data…
(370)
Disclaimer
The contents in this Java-Success are copyrighted and from EmpoweringTech pty ltd. The EmpoweringTech pty ltd has the right to correct or enhance the current content without
any prior notice. These are general advice only, and one needs to take his/her own circumstances into consideration. The EmpoweringTech pty ltd will not be held liable for any
damages caused or alleged to be caused either directly or indirectly by these materials and resources. Any trademarked names or labels used in this blog remain the property of
their respective trademark owners. Links to external sites do not imply endorsement of the linked-to sites. Privacy Policy
© 2024 800+ Big Data & Java Interview FAQs Responsive WordPress Theme powered by CyberChimps
Top
https://www.java-success.com/web-basics-interview-questions-and-answers/ 9/9