473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Accessing servlet from jsp

Hi,

I have one jsp and one servlet.

I am using a jsp in which i am entering some values like name, empid etc. and there is a dropdown list for location. I want when i select a particular location then a servlet is called in which i acess the values in an arraylist and uses
request.setAttribute,requestDispatcher and forward to pass these values to the first jsp.

Another dropdown on the jsp is populated using the values returned from servlet. Currently the servlet is called when the form is submitted. but i want it to be called onchange of location dropdown.

Another problem is that all the entered values before calling the servlet get reset to their initial values while these should remain as it was before calling the servlet.
How these problems can be solved?

Thanx
Oct 24 '07 #1
4 2263
Ferris
101 100+
hi

for your 1st problem,i have 2 sullutions.

1:using XMLHttpRequest(javascript) to call your servlet when your dropdown list is changed.(popular way)

2:you can reload your page by adding a new parameter in URL when list is changed.the jsp code in first.jsp will build a new dropdown according to the parameter.
for example:

open first.jsp ->
dropdown onchanged ->
open first.jsp?param=listvalue ->
listvalue -> jsp -> DB -> dropdown


for your 2nd problem:
if you use method 1 I give you,your entered value will not miss.
if you use method 2 ,you need to use jsp to rewrite the posted data into your input.


hope it helps.
Oct 24 '07 #2
hi

for your 1st problem,i have 2 sullutions.

1:using XMLHttpRequest(javascript) to call your servlet when your dropdown list is changed.(popular way)

2:you can reload your page by adding a new parameter in URL when list is changed.the jsp code in first.jsp will build a new dropdown according to the parameter.
for example:

open first.jsp ->
dropdown onchanged ->
open first.jsp?param=listvalue ->
listvalue -> jsp -> DB -> dropdown


for your 2nd problem:
if you use method 1 I give you,your entered value will not miss.
if you use method 2 ,you need to use jsp to rewrite the posted data into your input.


hope it helps.

Can u please send me some sample code?
Oct 24 '07 #3
Ferris
101 100+
hi

I'm sorry I have no sample code.I have told you how to do,so,you can google the code you want.
Oct 24 '07 #4
acoder
16,027 Expert Mod 8TB
Can u please send me some sample code?
See the Ajax example in the Articles section.
Oct 24 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hai Tran | last post by:
Any help is appreciated. Installed Tomcat 4.1 and Mysql on a WinXP. I've manage to get Tomcat up and was able to view my first application ( myhome ) simple home page. Tomcat was installed under...
5
by: TP | last post by:
Hi, I am doing my first database project using java servlets. We are going along fine but I have a question about how should one access a database. We have the URL, userid and pwd in a text...
4
by: Vasanth | last post by:
Hi: I am using Sun JdbcOdbcDriver to access MS-Access from Java client on Windows platform. We are in the process of migrating from Win to Solaris and AIX platform. MS-Access will continue to...
0
by: Ben | last post by:
Hi All, I have a web app which uses Frames, frame 1 with search criteria(1.aspx) and frame 2 with results(2.aspx). Frame2 in turn posts to a servlet(action="servlet URL") and the report parameters...
0
by: jchesser | last post by:
I have Servlet Filter that compresses the response of certain reports. The names for these reports are stored in an xml config file. Can someone explain how to access this config file from within...
1
by: itgaurav198 | last post by:
Hi, I have one jsp and one servlet. I am using a jsp in which i am entering some values like name, empid etc. and there is a dropdown list for location. I want when i select a particular...
0
by: krishna81m | last post by:
Could some one please explain why the session is not being maintained when I am doing a forward in a servlet after setting a cookie. I am even unable to set session attributes or parameters and...
6
by: Sushmita | last post by:
hi all, I have wrriten code for a small web application. From my JSP page i am not able to call the servlet.. its throwing an exception. "javax.servlet.ServletException: Wrapper cannot find...
1
by: shiyamala | last post by:
Hi i am shiyam, i am having some problem in java, i am basic java programmer. i have to write one program is writing the data into textfile name "newfile.txt" from one servlet and read it from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.