User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 426,486 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,253 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 845 | Replies: 4 | Solved
Reply
Join Date: Apr 2008
Posts: 2
Reputation: priyav is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
priyav priyav is offline Offline
Newbie Poster

restrict access of url addressbar

  #1  
May 7th, 2008
hai everybody,

i have a problem in jsp that i should access my application only by login. in my project when i give this url in my address bar "http://localhost:8080/jsp-examples/InvMgmt/test/stockrequisition.jsp". it directly goes to the stockrequisition page.

i dont know how to use the session variable. here i am sending stock requisition page please make a help for me.its urgent.

thanx in advance

 
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.PreparedStatement" %>



<html>
	<head>
		<script language="JavaScript" src="GCappearance.js"></script>
		<script language="JavaScript" src="GurtCalendar.js"></script>
		<link rel="stylesheet" href="calendar.css">
			<title>STOCK REQUISITION</title>
				<style type="text/css">
                  <!--
                    .style24 {font-family: Verdana, Arial, Helvetica, sans-serif; 

font-size: 12px; font-weight: bold; }
                    .style38 {font-size: 10px}
                    .style39 {font-family: Verdana, Arial, Helvetica, sans-serif; 

font-size: 12px; font-weight: bold; }
			
                  -->
                </style>


		<script language = "javascript">



function check()
		{
			if(document.frm1.n1.value=="")
			{
				alert("Please enter SR No");
				document.frm1.n1.focus();
			}
			else if(document.frm1.n2.value=="")
			{
				alert("Please enter Item ID");
				document.frm1.n2.focus();
			}
			else if(document.frm1.n3.value=="")
			{
				alert("Please enter SR Quantity");
				document.frm1.n3.focus();
			}
			else if(document.frm1.dataAreaTest.value=="")
			{
				alert("Please enter Date");
				document.frm1.dataAreaTest.focus();
			}
			else if(document.frm1.n4.value=="")
			{
				alert("Please enter SR Status");
				document.frm1.n4.focus();
			}
			else if(document.frm1.n5.value=="")
			{
				alert("Please enter From Party");
				document.frm1.n5.focus();
			}
			else if(document.frm1.n6.value=="")
			{
				alert("Please enter Remarks");
				document.frm1.n6.focus();
			}
			else
			{
			document.location.href=("stockinsert.jsp?srno=" + 

document.frm1.n1.value + "&itemid="+document.frm1.n2.value + "&srqty="+ 

document.frm1.n3.value + "&date=" + document.frm1.dataAreaTest.value + "&srstatus=" 

+ document.frm1.n4.value + "&fromparty=" + document.frm1.n5.value + "&remarks=" + 

document.frm1.n6.value);
			alert("Stock Requistion is Created");
			}
		}
		
		function reset()
        {
            frm1.n1.value="";
            frm1.n2.value="";
            frm1.n3.value="";
            frm1.n4.value="";
            frm1.n5.value="";
            frm1.n6.value="";
            frm1.n7.value="";
            frm1.n1.focus();
        }
		
function cancel()
{
if(document.frm1.n1.value=="")
{
alert("Please enter SRNo to search");
document.frm1.n1.focus();
}
else
{

document.location.href=("stockdelete.jsp?srno=" + document.frm1.n1.value);


}
}


		</script>
	</head>
	<body background="images/WSBackground_Songs1.jpg">
		<center><h2>STOCK REQUISTION</h2></center>
        <center>
			<form name="frm1" action="stockinsert.jsp" method="post">
            <center>
				<table width="800" border="0" cellspacing="5" 

cellpadding="0">
					<center>
                        <tr>
                           <td width="900" >        <table width="800" 

align="center" border="0" cellspacing="5" cellpadding="2">
								<tr>
									<td><span 

class="style39"></span></td>      
									<td><span 

class="style39"></span></td>
									

<td>&nbsp;</td>
                                    <td><span class="style39"></span></td>
                                    <td>&nbsp;</td>     
		<%
			Connection con=null;
			Statement st=null;
			ResultSet rs=null;
			try 
			{
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				con = DriverManager.getConnection

("jdbc:odbc:invent");
				String query="select max(SR_No) from 

Stock_Requistion";
				st=con.createStatement();
				rs=st.executeQuery(query);
				while(rs.next())
				{
		  %>	 
                                                     <td  align="left"><span 

class="style24">SR No: </span></td>
                                                    <td><input name="n1" type="text" 

title = "Please enter the SR No in the series of 1000...
For Eg: 1001" value="<%=rs.getInt(1)+1%>"></td>
		  <%
		} 
		 
	 } catch (Exception e) {
        //Handle exception
        System.out.println(e);
    } finally {
        try {
            rs.close();
            st.close();            
            con.close();
        } catch (Exception e) {
            //Handle exception
        }
	}
			  %>                                             
                                                   <td><span 

class="style39"></span></td>
                                                                                     

          
                                                 <td><span 

class="style39"></span></td>
                                                  <td>&nbsp;</td>
 <td><span class="style39"></span></td>
                                                     <td>&nbsp;</td>
                                                   <td align="left"><span 

class="style24">Item ID: </span></td>
                                                   <td><input name="n2" type="text" 

title= "Please enter the Item ID like the example given below
For Eg: i001"></td>
											

		
                                                  <td><span 

class="style39"></span></td>
                                                    <td><span 

class="style39"></span></td>
 <td align="left"><span class="style24">Requested Delivery Date:</span></td>
<td>
    <script language="JavaScript">
<!--		
var GC_SET_0 = {
	'appearance': GC_APPEARANCE,
	'dataArea' : 'dataAreaTest'
}
new gCalendar(GC_SET_0);
//-->
</script></td>           
</tr>
                 </tr>            

    
                 <tr>
<td><span class="style39"></span></td>
                                      <td><span class="style39"></span></td>
                                                     <td>&nbsp;</td>
                                              <td><span class="style39"></span></td>
                                                    <td>&nbsp;</td>
                                                  <td align="left"><span 

class="style24">SR Quantity: </span></td>
                                                  <td><input name="n3" type="text" 

title="Please enter numeric values"></td>
                                                   <td><span 

class="style39"></span></td>
                                                  <td><span 

class="style39"></span></td>

                        <td><span class="style39"></span></td> <td>&nbsp;</td>     
                        <td><span class="style39"></span></td>
                                                                                   
                         <td align="left"><span class="style24">SR Status: 

</span></td>
                         <td><input name="n4" type="text" title="Please enter the SR 

Status like the example given below
For Eg: active or inactive"></td>
 <td><span class="style39"></span></td>
<td><span class="style39"></span></td>
                       </tr>
<tr>
<td><span class="style39"></span></td>
                                                    
<td><span class="style39"></span></td>
                                                     <td>&nbsp;</td>
<td><span class="style39"></span></td>
                                                     <td>&nbsp;</td>
                       <td align="left"><span class="style24">From 

Party:</span></td>
                      <td><input name="n5" type="text" title= "Please enter the From 

Party like the example given below
For Eg: s001"></td>
 <td><span class="style38"></span></td>
<td><span class="style39"></span></td>
                     
  
<td><span class="style39"></span></td>
                                                     <td>&nbsp;</td>
<td><span class="style39"></span></td>
                                                     
            <td align="left"><span class="style24">Remarks: </span></td>
            <td><input name="n6" type="textfield" title= "Please enter the Remarks 

like the example given below
For Eg: success or failed"></td>
             <td><span class="style39"></span></td>

           </tr>
</center></table>
<table>
<tr>


           
</table>

       <br>
   <center>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input name="btn"type="button" value="CREATE SR" onClick="check()" >
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;<INPUT TYPE="reset" onClick=reset() value="RESET">&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;<INPUT TYPE="button" name="can" onClick=cancel() value="CANCEL 

SR"></center>
  </center> 
</center>
</form>

</body>

</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: restrict access of url addressbar

  #2  
May 7th, 2008
Redo from start.
Not urgent.
Rubbish code.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Apr 2008
Posts: 2
Reputation: priyav is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
priyav priyav is offline Offline
Newbie Poster

Re: restrict access of url addressbar

  #3  
May 8th, 2008
hi jwenting,
if u dont like to give any solution be quiet. dont scold any body. the code is working correctly.it is not a rubish code.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: restrict access of url addressbar

  #4  
May 8th, 2008
It is rubbish. It is fundamentally flawed by design.
If you don't want to hear advice you don't like, don't ask questions.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,458
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 11
Solved Threads: 296
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: restrict access of url addressbar

  #5  
May 9th, 2008
jwenting is correct, you are using JSP for incorect purpose. Database connection have to be managed through servlet not JSP as you did. It is still possible by JSP but that is wrong
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the JSP Forum

All times are GMT -4. The time now is 4:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC