Jsp code to enable and disable certain links using jsp code

Jsp code to enable and disable certain links using jsp code

Hi Everyone,

I have a doubt in JSP,I have created a web application which has priviledges of a superuser and guest..now if a superuser logs in the page gets redirected to home page where all the links under a menu should be visible and enabled whereas when a guest logs in he should be redirected to the same home page but with only a certain links only visible and enabled. now my doubt is how can i write the code to disable these links..
Can anyone help me?? its really really urgent.................!!
Please :)

Thanks in advance
Debo
View Answers

May 28, 2010 at 12:19 PM

Hi Friend,

Try the following code:

1)login.html:

<html>
<head>
</head>
<body>
<form name="form" method="post" action="http://localhost:8080/examples/jsp/mod.jsp">;
<br><br>
<table align="center"><tr><td><h2>Login Authentication</h2></td></tr></table>
<table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;">
<tr><td colspan=2></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr>
<td><b>Login Name</b></td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="password" value=""></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td></td>
<td align="right"><a href="register.html">New User?</a></td>
</tr>
</table>
</table>
</form>

</body>
</html>

2)mod.jsp:
<%@page import="java.sql.*"%>
<html>
<body>
<%
String user=request.getParameter("username");
String pass=request.getParameter("password");
%>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from user where username='"+user+"' and password='"+pass+"'");
String username="";
String pwd="",type="";
while(rs.next()){
username=rs.getString("username");
pwd=rs.getString("password") ;
type=rs.getString("type") ;
}
if(user.equals(username)&&pass.equals(pwd)){
response.sendRedirect("home.jsp?user="+user+"&&type="+type);

}
else
{
response.sendRedirect("login.html");
}
}
catch(Exception e)
{}
%>
</body>
</html>

3)home.jsp:

<%
String name=request.getParameter("user");
String type=request.getParameter("type");
System.out.println(type);
%>
Welcome <%=name%>,<br><br>
<%
if(type.equals("superuser")){
%>
<a id="one" href="edit.jsp">Edit Profile</a><br>
<a id="two" href="view.jsp">View Profile</a><br>
<a id="three" href="delete.jsp">Delete Profile</a>
<%
}
else{
%>
<a id="two" href="view.jsp">View Profile</a><br>
<%
}
%>

Thanks

May 28, 2010 at 12:56 PM

Thank u so much....I will try to use this code to get some help... :)

May 28, 2010 at 12:57 PM

Thank u so much....I will try to use this code to get some help... :)

May 28, 2010 at 1:22 PM

Hi,

As per the code u posted i tried to apply it...but i have used sessions in my code.For the particular session used i have to enable/disable a link.I need a code to do that.

Thanks in advance :)









Related Tutorials/Questions & Answers:
Jsp code to enable and disable certain links using jsp code - Java Beginners
Jsp code to enable and disable certain links using jsp code  Hi... write the code to disable these links.. Can anyone help me?? its really really... have to enable/disable a link.I need a code to do that. Thanks in advance
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
Advertisements
jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code for searching fromwhole database. I am using Oracle10g Database.   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
jsp code
jsp code  what are the jsp code for view page in online journal
JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
jsp code
jsp code  i want health management system project code using jsp.its urgent
JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code
jsp code
jsp code  i want to jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type code,,,,plz help me
how to enable and disable a input type in jsp - JSP-Servlet
how to enable and disable a input type in jsp  how to disable the input type and enable based on some input in the input type   Hi Friend, Try the following code: function function1(){ var n
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code... friend, Code to solve the problem : Thanks
jsp code - JSP-Servlet
jsp code  how to count no of clicks made on a link and save it on database( using jsp)  Hi Friend, Try the following code: 1)click.jsp var numberOfClicks = 0; function hello(){ numberOfClicks
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message
JSP code - JSP-Servlet
me how to link these pages with each other using JSP..and how to write the code using JSP.. requriment for Newuser: 1>fname,lastname 2>Loginname...JSP code  hello,i working in project with JSP technology,i have one
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
jsp code - JSP-Servlet
jsp code  sample code for change password example Old Password: new Password: confirm Password
JSP Code - JSP-Servlet
, Please visit the following links: http://www.roseindia.net/jsp/data-grid.shtml http://www.roseindia.net/jsp/paging.shtml Thanks...JSP Code  Hi, Do we have a datagrid equivalent concept in JSP
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
jsp code - JSP-Servlet
jsp code  sample code to create hyperlink within hyperlink example: reservation: train: A/C department non A/c Department
jsp code - JSP-Servlet
jsp code  in a jsp a table is existed ,in table each row contain one checkbox and name and desription how to delete specific rows in a table .  Hi Friend, Try the following code: 1)form.jsp: Name
jsp code - JSP-Servlet
jsp code  how to write a code in jsp with out using servelts finding sum and avg of 40 numbers  Hi Friend, Try the following code: Thanks  Hi Friend, Do one change in the provided code.As we
jsp code - JSP-Servlet
jsp code  Hello Everybody, can anyone help me to findout the modules as i am developing a whiteboard application using jsp? this application is my dream application. Thank you
jsp code - JSP-Servlet
jsp code  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get table of item details of that orderid... there are multiple items at one orderid
JSP Code - JSP-Servlet
JSP Code  Create a html reader JSP tag that read the html page from a link and will display the contents on the JSP. Do not use include directive
jsp code - JSP-Servlet
to generate second drop down list by using jsp? pls ?   Hi Friend...jsp code  hi my requirement is generate dynamic drop down lists... the second drop down list is displayed from mysql data base table by using select
code in jsp
code in jsp  hi.. I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a code to sort a list of students on the basis of there 12% marks and AIEEE
jsp code - JSP-Servlet
jsp code  i want to add below code data in mysql database using jsp... using below code we got data in text box i want to add multiple data in database... Add/Remove dynamic rows in HTML table
JSP Code - JSP-Servlet
JSP Code  Hi, I have a problem in limiting the number of row... to display only 10 records per pages in jsp, then how can i achieve this concept... Rai.  Hi Friend, Try the following code: Pagination
jsp code - JSP-Servlet
jsp code   the value did not passed from script and not inserted in to database in the code u given . var numberOfClicks = 0; function hello(){ numberOfClicks++; alert( numberOfClicks ); document.form1.text.value
JSP code - JSP-Servlet
JSP code  hi i want to clear text box fields after click on submit.... thanking u......... This is what my code is. Jam Name...;   Hi Friend, Try the following code: Jam Name
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code:ADS_TO_REPLACE_1 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/jsp
jsp code - JSP-Servlet
jsp code  how to get multi-chat client using jsp? i will be very glad if i'd get an idea from you people. thank you .  Hi Friend... (which runs on client side). This application is using for chatting in LAN
populating text box using jsp code
. Please give an example using jsp code only.   dependentDropdown.jsp...populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql
jsp code - JSP-Servlet
jsp code  hello frns i want to display image from the database along... from database in Jsp to visit.... http://www.roseindia.net/jsp/retrieve-image.shtml http://www.roseindia.net/jsp/downloadimage.shtml Thanks
jsp code - JSP-Servlet
jsp code  hi i am doing project work i am generating time table for this i have taken form courseyear textbox semistername textbox no of periods... will be allotted to six days. pls send me code for this pls thankyou
JSP code - JSP-Servlet
JSP code  Hi! Can somebody provide a line by line explanation of the following code. The code is used to upload and download an image. <... have successfully upload the file by the name of: Download /*Code
jsp code - Java Beginners
JSP code and Example  JSP Code Example
jsp code plz
;Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml The above links...jsp code plz  write jsp code which takes student roll number as input
jsp code - JSP-Servlet
jsp code  i want to add and remove rows dynamically ... in that row 3 colums are there... first colum shows one number , second colum shows second... colum.  Hi Friend, Try the following code: Add/Remove
jsp code - JSP-Servlet
jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page of hyperlink 4) bottom page has to display footer example header
jsp code - JSP-Servlet
jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page of hyperlink 4) bottom page has to display footer example header
Jsp code for disabling record.
Jsp code for disabling record.  I want a Jsp and servlet code for the mentioned scenario. Q. A cross sign appears in front of each record, click to disable the record.System marks the record as disabled.The record
Jsp code - JSP-Servlet
Jsp code  PlaceAd.jsp function Calculate() { var fpval; var cityamt; var newspaper; var sizeval; var city = document.form.city.value; var noofwd = document.form.Count.value
Jsp code - JSP-Servlet
Jsp code   function Calculate() { var fpval; var cityamt; var newspaper; var sizeval; var city = document.form.city.value; var noofwd = document.form.Count.value; var nofw
Jsp Code Problem - JSP-Servlet
Jsp Code Problem  I use DocType in my Jsp Page. The Links are not functioned after Applying the DocType. Could you tell me any way to activate the link. Thank You.   Hi Friend, Please send your code. Thanks
insert code jsp to access
insert code jsp to access   insert code jsp to access
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page

Ads