473,546 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hw to assign value and display it into the jsp through servlet

1 New Member
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.tx t" 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.Buffere dReader;
import java.io.FileRea der;
import java.io.IOExcep tion;
import java.util.Strin gTokenizer;
import java.util.Vecto r;

import javax.servlet.R equestDispatche r;
import javax.servlet.S ervlet;
import javax.servlet.S ervletException ;
import javax.servlet.h ttp.HttpServlet ;
import javax.servlet.h ttp.HttpServlet Request;
import javax.servlet.h ttp.HttpServlet Response;

import myPack.Firstapp ;


/**
* @version 1.0
* @author
*/
public class Appsecondservle t extends HttpServlet implements Servlet {

/**
* @see javax.servlet.h ttp.HttpServlet #void (javax.servlet. http.HttpServle tRequest, javax.servlet.h ttp.HttpServlet Response)
*/
public void doGet(HttpServl etRequest req, HttpServletResp onse resp)
throws ServletExceptio n, IOException {
doPost(req,resp );

}

/**
* @see javax.servlet.h ttp.HttpServlet #void (javax.servlet. http.HttpServle tRequest, javax.servlet.h ttp.HttpServlet Response)
*/
public void doPost(HttpServ letRequest req, HttpServletResp onse resp)
throws ServletExceptio n, IOException {
Firstapp a1=new Firstapp();

//public static void main(String arg[]){
try
{
FileReader f2=new FileReader("c:\ \NEWFILE.txt");

BufferedReader input = new BufferedReader( f2);
Vector v=new Vector();
String line = input.readLine( );
while (line!= null) {

StringTokenizer st = new StringTokenizer (line,";");
while (st.hasMoreToke ns()) {
String next= st.nextToken();
a1.setFinNo(req .getParameter(" next"));

v.addElement(ne xt);
//System.out.prin tln(line);
//System.out.prin tln(next);


}System.out.pri ntln("\n");
line = input.readLine( );
}
input.close();
f2.close();


} catch(IOExcepti on e){}

RequestDispatch er disp=getServlet Context().getRe questDispatcher ("/Secondjsp.jsp") ;
req.setAttribut e("myapp1",a1 );
}
}


help me thankyou
Feb 4 '08 #1
1 2136
r035198x
13,262 MVP
1.) Please use code tags when posting code.
2.) You should set the attributes before calling getRequestDispa tcher.
Feb 4 '08 #2

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

Similar topics

2
22158
by: kaiwing18 | last post by:
Hi, I have a following jsp file called "showAsset.jsp" : <form action="showAsset.jsp" method="post"> <tr BGCOLOR=YELLOW> <td><input name="sort" type="submit" value="Asset_Number" > </td> <td><input name="sort" type="submit" value="Description"></td>
1
3882
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 ...
9
6491
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key" labelProperty="value"/> In this case "key" is what I mean by "ID", and "value" is what I mean by "Value" -- the "Value" is shown to the user, but the "ID" is what I...
1
5963
by: efiedler | last post by:
Hi - I have the following input field on my html page: <input type="image" name="submit" id="submit" src="c:\image.jpg" value="image.jpg"> I also have another input field on the form that is a text box. When submitted my form posts its data to a servlet. I can click on the image, and the form is posted and the servlet is ran. However, I...
2
2133
by: Harry Stangel | last post by:
Noble reader, My goal is to obtain the current time on the web server and display it in the client's browser. I want the server time displayed independent of the client's current clock setting, but use the client clock to refresh the displayed time every second. To compensate for drift, I want to periodically calibrate the page with the...
8
6309
by: Ryan | last post by:
I have a hidden field as such: <INPUT TYPE=\"hidden\" name=xmlfield > I have a button that i want to use to call a function to change the value: <INPUT TYPE=submit VALUE="Display XML" Name="displayXML" OnClick="ChangeFieldName('XML')"> here is the function
4
2955
by: Bilwin | last post by:
Hi friends, I would like to know how can i pass values to AJAX form from a servlet and how to display that value in a drop down box. Plz help me on this since i am a newbie to this. Thanks Bilwin.
1
3769
by: Java Kumar | last post by:
Hi Pals, I need your help regarding following problem.Im working in MVC model application which has jsp, servlet,and bean file. By the flow of application , I have to display datas in jsp page which stored in a DB. And also I can display those datas in a table by using <td><%=rs.getString(1)%> statement. This jsp has text boxes. So I...
3
3078
by: vijaykumardahiya | last post by:
Hello To Every One, I want to know that when I upload the File like a image from html page Its not show on servlet page using appropriate logic. I read the FileUpload Home page.But I am still confused. Is that true that file uploaded image can not show on servlet.Its store to database or memory..?? Please assist me. Thanks.
0
7504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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...
1
7461
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7792
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...
0
5080
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...
0
3491
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...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.