473,804 Members | 3,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing servlet from jsp

41 New Member
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.setAttr ibute,requestDi spatcher 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 2283
Ferris
101 New Member
hi

for your 1st problem,i have 2 sullutions.

1:using XMLHttpRequest( javascript) to call your servlet when your dropdown list is changed.(popula r 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
itgaurav198
41 New Member
hi

for your 1st problem,i have 2 sullutions.

1:using XMLHttpRequest( javascript) to call your servlet when your dropdown list is changed.(popula r 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 New Member
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 Recognized Expert Moderator MVP
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
3901
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 C:\Tomcat4\ with C:\Tomcat4\webapps\myhome\WEB-INF\classes to store all my java.class files. Under WEB-INF, I've have edit the web.xml file as <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD...
5
1532
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 secured file or maybe in web.xml. somewhere where the user does not access it.
4
4448
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 reside on Win platform. How can I access MS-Access from Java client on Solaris and AIX? Can I still use Sun JdbcOdbcDriver?. What drivers or files do I need on Solaris and AIX platforms? If Sun JdbcOdbcDriver for MS-Access is not possible on these...
0
1137
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 are expected as hidden variables on the form(of 2.aspx). The workflow is simple, the user selects diff values for drop downs and then hits Run(which calls some javascript code), which would populate hidden variables on 2.aspx, and then submit...
0
987
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 the filter and what the best way is to compare the list of reports to the current response url?
1
1216
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 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...
0
2652
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 do a forward from a servlet to another servlet via a JSP page, the attributes seize to exist. I still do not understand the concept of session tracking. First page JSP: _______________________________________________ <%@ page...
6
4475
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 servlet class servlet.IssueTrackerControllerServlet or a class it depends on org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39) ...
1
2152
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 another servlet its work but i want to know hw to deploy the readed input from textfile is displayed in jsp through servlet2. here is my code import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import...
0
9579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10076
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.