473,473 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to forward in jsp page

9 New Member
Hye......

In my jsp page i m usin javascript & i m forwarding to the next page usin location.href but its not working Plz help...
Here is the code:

addProject.jsp

Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.sql.*" %>
  2. <%@ page import="java.io.*" %>
  3. <%@ page import="java.util.Arrays" %>
  4. <html>
  5. <head>
  6. <title>Add Project</title>
  7. </head>
  8. <body>
  9.  
  10. <form name="f1" >
  11.     <font size=4 face="Verdana" color=#120292>
  12. <%
  13.     Connection con;
  14.     ResultSet rs;
  15.     String arr[];
  16.     try
  17.     {
  18.     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  19.     con=DriverManager.getConnection("jdbc:odbc:pc","","");
  20.     String query=null;
  21.     query="select pname from programmers where prname=''";
  22.     Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
  23.     rs=stmt.executeQuery(query);
  24. %>
  25.     <br>
  26. <table cellspacing=10 cellpadding=10 bgcolor=#959999 colspan=5 rowspan=5 align="center">
  27.         <tr>
  28.             <td><strong> Add Project Form</strong></td>
  29.         </tr>
  30.         <tr>
  31.             <td>Enter Project Name :</td>
  32.             <td><input type=text name="prname"></td>
  33.         </tr>
  34.         <tr>
  35.             <td>Enter Project Language: </td>
  36.         <td><input type=text name="prlang"></td>
  37.         </tr>
  38.         <tr>
  39.         <td>Select Programmers :</td>
  40.         <td><SELECT id=sel name=f>
  41.         <%
  42.         while(rs.next())
  43.         {
  44.         String s=rs.getString("pname");
  45.         %>
  46.                         <OPTION value=cp><%out.println(s);%></OPTION>
  47.         <%
  48.           }
  49.         }
  50.     catch(Exception e)
  51.     {
  52.     out.println(e.toString());
  53.     }
  54.  
  55.     %>
  56. &nbsp;&nbsp;<input type="button" value="Add" onClick="cfun(sel)"></td></tr>
  57.     <tr><td>Selected Programmers : </td>
  58.         <td><TEXTAREA NAME="prog" ROWS=5 COLS=10WRAP="VIRTUAL"></TEXTAREA>
  59.         </tr>
  60.         <tr>
  61.             <td>Enter Project Description: </td>
  62.         <td><TEXTAREA NAME="desc" ROWS=4 COLS=20 WRAP="VIRTUAL"></TEXTAREA>
  63.         </tr>    
  64. </table>    
  65. <br>
  66. <table align="center">
  67.  <tr>
  68. <td><input type="submit" value="        Ok          " onclick="empty(prname,prlang,prog,desc)"></td>
  69. <td><input type="Reset" value="         Clear         " ></td>        
  70. </tr>
  71. </table>
  72. </font>
  73. </form>
  74. <script language=JavaScript>
  75. bh=0
  76. inc=0
  77. k=0
  78. flag=0
  79. temp=new Array()
  80. function cfun(sel)
  81. var value = sel.options[sel.selectedIndex].text
  82. temp[inc]=value
  83. if(inc>0)
  84. {
  85. for (i = 0; i<temp.length-1; i++)
  86. {
  87. if (temp[i]==temp[inc])
  88. {
  89. flag=1
  90. break
  91. }
  92. else
  93. flag=0
  94. }
  95. if(flag==0)
  96. document.f1.prog.value=document.f1.prog.value+value+"\n"
  97. else
  98. alert("Already added !")
  99. }
  100. else
  101. document.f1.prog.value=document.f1.prog.value+value+"\n"
  102. inc++
  103. }
  104. function empty(prname,prlang,prog,desc)
  105. {
  106. var value1=document.f1.prname.value
  107. var value2=document.f1.prlang.value
  108. var value3=document.f1.prog.value
  109. var value4=document.f1.desc.value
  110. if(value1==''||value2==''||value3==''||value4=='')
  111. alert("Please dont leave blank field !")
  112. else
  113. window.location.href="C:\\Projectcontrolold\\Server\\project.jsp"
  114. }
  115. </script>
  116. </body>
  117. </html>
  118.  
Aug 9 '09 #1
3 4344
gits
5,390 Recognized Expert Moderator Expert
the url is absolute and a local file? is that your intention?
Aug 10 '09 #2
kabburebh
9 New Member
Ya its local file.The addProject.jsp & project.jsp are in same folder ie in Projectcontrolold but its not forwarding.
Aug 11 '09 #3
gits
5,390 Recognized Expert Moderator Expert
when it is in the same folder then you should use a relative path:

Expand|Select|Wrap|Line Numbers
  1. window.location.href="project.jsp";
doesn't that work?
Aug 12 '09 #4

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

Similar topics

2
by: DiggidyMack69 | last post by:
Hello all, I use <jsp:forward page="" /> tag in a couple JSP's I've written and was wondering if there is an equivalent when writting Java servets? thanks, DM
10
by: pmelanso | last post by:
Hello, How can I tell if there is a page to go back to in the history or not??? Same with forward??? say something like/// if (there is a page to go back to ) { // DO something }else { }
5
by: Brad | last post by:
I created a base page class which sets a response filter and the filter injects additional html into the response output stream. The filter works fine and everything works as expected except for...
6
by: Kent Boogaart | last post by:
Hi, If I know a type which extends System.Web.UI.Page, is there any way I can figure out what the URL for that page is? The closest I've come to this is to: 1. Construct an instance of the...
8
by: Tracey | last post by:
Hi, guys. My application requires functionalities like back and forward navigating button on winforms. And there are many forms linking each other. Each form has a pair of buttons of "Back" and...
2
by: CaptainDahlin | last post by:
I know the basics about access reports and putting page totals in the page footers. What I can't figure out is along with the current page total to display the previous page total: At the bottom...
0
by: parameswar | last post by:
Hi Friends I Have Worked In J2ee (struts).for Example I Am Creating A Login Page In J2ee I Have To Create A Context Directory,then I Have To Configure My Struts.config File,server.xml File In Conf...
5
dmjpro
by: dmjpro | last post by:
Could anyone tell me what is difference between jsp:forward and RequestDispatcher.forward? These two codes behave differently ... <jsp:forward page="page_ref"/> and
3
oranoos3000
by: oranoos3000 | last post by:
hi i'm a beginer javascript would you please help me i d like to findout this page has next page or previous page in history object i use this line of code if(window.history.length>0) and with...
3
by: Akino877 | last post by:
Hello, I have a Java Swing application that I would like to be able to forward to or to run it - sorry, I am not sure if I am using the right term - from a JSP page. And I would like for my Java...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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,...
1
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,...
1
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...
0
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...

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.