Go Premium for a chance to win a PS4. Enter to Win

x

JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm following this LDAP authentication code

LDAP Authentication code

replaced parameters with my own parameters to authenticate  with OpenLDAP 2.4.31


public static void main(String[] args)
	{
		String username = "jsmith";
		String password = "password@123"; 
		String base = "ou=people,dc=nodomain";
		String dn = "uid=" + username + "," + base;
		String ldapURL = "ldap://xx.xx.xx.xx:389";

		// Setup environment for authenticating
		
		Hashtable<String, String> environment = 
			new Hashtable<String, String>();
		environment.put(Context.INITIAL_CONTEXT_FACTORY,
				"com.sun.jndi.ldap.LdapCtxFactory");
		environment.put(Context.PROVIDER_URL, ldapURL);
		environment.put(Context.SECURITY_AUTHENTICATION, "simple");
		environment.put(Context.SECURITY_PRINCIPAL, dn);
		environment.put(Context.SECURITY_CREDENTIALS, password);

		try
		{
			DirContext authContext = 
				new InitialDirContext(environment);
			System.out.println("authentication success!");
			
			// user is authenticated
			
		}
		catch (AuthenticationException ex)
		{
			System.out.println("authentication failed!");   // I'm getting this print
			// Authentication failed

		}
		catch (NamingException ex)
		{
			ex.printStackTrace();
		}
	}
}

Open in new window


I am getting authentication failure message . ..what I'm doing wrong ?  ..unable to find the root cause.
Do I need to send password encrypted  ?
0
Concerto's Cloud Advisory Services
LVL 5
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Dear,
What driver to choose below, when creating Database connection, to connect to SQL server DB?
18r.png
0
Hello,

Need to clean cache of client browser,using jsp as front end.
though have already written the below code

 <% response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 
 response.setHeader("Pragma","no-cache"); //HTTP 1.0 
 response.setDateHeader ("Expires", 0); //prevents caching at the proxy server  
%>

Open in new window


But almost 90% of the times we need to ask the client to manually clean the cache,after that only the new changes are reflected in the client browser,say we have created new button on screen, which is not visible but when the user cleans the browser cache manually the button seems to work display.
0
Hi,

I have a requirement in Java script to run the select statements every 3 hours and update those select count(*) counts in a spreadsheet. Kindly share the code snippet to accomplish this request.

Also we are running

1. 2 scripts 3 hours once in a day.
2. 1 Script once in a day.
3. 1 script on particular times like 10.45, 11.15....

please let me know if you need any more details.

Thanks
Venkatesh.
0
Hi - I have the below line in my jsp and i am getting error saying
unterminated &lt;

 
var myString = "<img src='images/clear.gif' width='8' height='5'><mytags:dropdown  fieldID=" +"'"+ extDataID+ "'"+" category= " +  '<%=com.test.myString.GET_VALUE_TEST%>' + " selectedOption='' style='InputFields'/>";
			

Open in new window


so what is wrong in the above syntax is javascript not accepting <%= %>

I can pinpoint the error to this line because when i replace the above line with the below line no issues
var myString = "<img src='images/clear.gif' width='8' height='5'><input type='text' name=" +"'"+ test+ "'"+" maxlength = '40' size='64' value='' class = 'InputFields'>";

Open in new window


Thanks,
0
I have the following class definition:
class PurchaseData {
    public BigDecimal purchaseYears,
        contribRate,
        milYears,
        lapsedTime, lapsedTime2, lapsedTime3,
        factor,
        purchaseCost, purchaseCost2, purchaseCost3,
        paymentAmount;
    
    PurchaseData(BigDecimal py, BigDecimal cr, BigDecimal my,
        BigDecimal l1, BigDecimal l2, BigDecimal l3,
        BigDecimal f,
        BigDecimal p1, BigDecimal p2, BigDecimal p3,
        BigDecimal pa)
    {
        purchaseYears = py;
        contribRate = cr;  
        milYears = my;   
        lapsedTime = l1; 
        lapsedTime2 = l2;
        lapsedTime3 = l3;
        factor = f;
        purchaseCost = p1; 
        purchaseCost2 = p2;
        purchaseCost3 = p3;
        paymentAmount = pa;
    }
} 

Open in new window

Note that, all by itself, that class definition compiles w/o errors.

In my program I do the following:
PurchaseData rd = new PurchaseData();
//and I've tried:
PurchaseData rd = new PurchaseData(null,null,null,null,null,null,null,null,null,null,null);

Open in new window

when I try to run, I get:
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 2,068 in the jsp file: /purchaseServiceCredit.jsp
The constructor purchaseServiceCredit_jsp.PurchaseData() is undefined

Open in new window

What am I doing wrong?
0
I'm very new to unifi, html and css. Please be gentle with me.
I have the current windows version of the Ubiquiti Unifi controller.
I am able to modify voucher.html and voucher.css to produce custom hotspot vouchers.
I want to print, on the voucher, the date and month the voucher was created.
I have added the following line to voucher.html:
<div class="create_time">Create Time: <unifi var="create_time" /></div>
 
The voucher prints "Create Time:" but does not print the date/time.
Any assistance is much appreciated.
0
Hi - I wrote the below functions/html to create 10 more dropdowns upon clicking the button, but for some reason it is not working.
what am i doing wrong ?

My requirement:
I have 5 dropdowns on left side and right side by default
when i click on add 10 rows button i should see 10 more dropdowns on left side and 10 more  dropdowns on right side (total 15)

<!DOCTYPE html>
<html>
<body>

<script>
function addDataRows(divname) {
   var newDiv=document.createElement('div');
   var html = '<select>
		<option value="volvo">Volvo</option>
		<option value="saab">Saab</option>
		<option value="opel">Opel</option>
		<option value="audi">Audi</option>
		</select>';
   newDiv.innerHTML= html;
   document.getElementById(divname).appendChild(newDiv);
}
function addLRows(divname) {
   var newDiv=document.createElement('div');
   var html = '<select>
				<option value="volvo">Volvo</option>
				  <option value="saab">Saab</option>
				  <option value="opel">Opel</option>
				  <option value="audi">Audi</option>
				</select>';
   newDiv.innerHTML= html;
   document.getElementById(divname).appendChild(newDiv);
}
function add10rows(Container1, Container2){
	var rowCnt;
	for(rowCnt = 1; rowCnt<11; rowCnt++) {
		addDataRows(Container1)
		addLRows(LocContainer)
	}
}
</script>
<table>
<tr>
	<table>
		<td align="left" nowrap width="40%" style="padding-left: 10px; padding-bottom: 10px">
				<select>
				<option value="volvo">Volvo</option>
					<option value="saab">Saab</option>
				  

Open in new window

0
i am new to rest api.
i want to implement REST API for my project which is developed with Spring framework.
i want to implement  REST API in best way.

Please provide sugggistions for design and development.
0
I have my code like below
      response = orch.process(request);

when i mover on to process method and click control and left mouse click it supposed to go to process method implementation but it is not doing in eclipse mars.

it used to work earlier not sure suddenly what happened stops working.

i restarted my laptop still not working.

please advise
0
How to Use the Help Bell
LVL 11
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

java.lang.ClassNotFoundException this error occurs in jsp page after changes made in jsp.This kind of error occurred after update jRun4 with updater 7 using java 1.6 how to handle this error pls help.
0
I was reading about Resource Bundles

as below
internationalization feature of the JDK provides a mechanism for separating user interface (UI) elements and other locale-sensitive data from the application logic in a program.
I can relate with local sensitive data separation but not the UI elements like buttons etc why we need to separate?

pelase advise
0
i am using jsp page to insert some value but when the parameters get to the servelet the values received are null when I am using Post method but when Get method is used then it works fine.
request.getParameter() is returning null value when post method is used but when get method is used it works fine and the values get inserted

anyone have idea how to fix this???

//Jsp Page

<%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="insert.css">
    <title>Database Update</title>
    </head>
    <body>
    <h1 class="main-header">Enter the Details</h1>
    <div class="fullbody">

    <form action="Insert" method="post" enctype="multipart/form-data">
    <div class="text">
    <b>Stuid:</b>
    <input type="text" placeholder="stuid" name="stuid" pattern=[0-9]{1,} title="can only have numeric value" required>
    <b>Student Name:</b>
    <input type="text" placeholder="student name" name="name" pattern="[A-Za-z ]{1,45}" title="can only have alphabet and space" required>
    <b>Student Mobile no.:</b>
    <input type="text" placeholder="student mobile no." name="stumob" pattern=[0-9]{10} title="10 digit number" required>
    <br>
    <b>Father's Name:</b>
    <input type="text" …
0
I have a legacy system developed 10 years ago.

 A jsp page---SalesEditBillingAddress.jsp

<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" > 
<jsp:param name="dept" value="sales"/>
</jsp:include>    

Open in new window


second jsp page---marketingEditBillingAddress.jsp

<jsp:include page="/WEB-INF/forms/include/edit_billing_address.jsp" > 
<jsp:param name="dept" value="marketing"/>
</jsp:include>    

Open in new window


The reason to pass the parameter is because the generic page----edit_billing_address.jsp has different form action need to be submitted based on different parameters.

  <html:form action="/actions/${param.dept}/editBillingAddress">
<html:text name="customerBillingAddressBean" property="address1"  maxlength="60"> </html:text> 
.............
<html:text name="customerBillingAddressBean" property="contact" maxlength="60"></html:text>
<html:text name="customerBillingAddressBean" property="email" maxlength="80"></html:text>

<button type = "submit" class ="btn btn-primary">Submit</button>		   
</html:form>        

Open in new window



however, tomcat 8.0 with java 1.8 complain about this line of code:
<html:form action="/actions/${param.dept}/editBillingAddress">

Open in new window


javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot retrieve mapping for action /actions/${param.dept}/editBillingAddress

The example on this page:

http://beginnersbook.com/2013/12/jsp-include-with-parameter-example/

shows that my code is nothing wrong about it.

my question is: how to make the parameter work in the action URL?

I also tried the following code:

			 
			 <c:set var="myVar" value="${param.dept}" />

			 <c:if test = "${myVar eq 'sales'}">
			   <html:form action="/actions/sales/editBillingAddress">  
			 </c:if>
		    
		        <c:if test = "${myVar eq 'marketing'}">
			   <html:form action="/actions/marketing/editBillingAddress">
		         </c:if>

                ............. many input fields ...............

                        <button type = "submit" class ="btn btn-primary">Submit</button>		           
	                </html:form>        
	  

Open in new window


but it doesn't work because the eclipse compiler give error message due to only one closed form tag could be found.
0
[root@web02 ~]# cat /etc/*-release
CentOS release 6.8 (Final)
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
CentOS release 6.8 (Final)
CentOS release 6.8 (Final)

[root@web02 ~]# yum info -v apache-tomcat-apis
Loading "fastestmirror" plugin
Config time: 0.076
Yum Version: 3.2.29
rpmdb time: 0.000
Setting up Package Sacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.rafal.ca
 * extras: centos.mirror.rafal.ca
 * updates: ca.mirror.babylon.network
pkgsack time: 0.126
Installed Packages
Name        : apache-tomcat-apis
Arch        : noarch
Version     : 0.1
Release     : 1.el6
Size        : 246 k
Repo        : installed
From repo   : base
Committer   : Andrew Overholt <overholt@redhat.com>
Committime  : Tue Feb  2 07:00:00 2010
Buildtime   : Wed Nov 10 19:18:17 2010
Install time: Sun May 28 11:58:23 2017
Installed by: root <root>
Changed by  : System <unset>
Summary     : Tomcat Servlet and JSP APIs
URL         : http://tomcat.apache.org/
License     : ASL 2.0
Description : Apache Tomcat's Servlet 2.4/JSP 2.0 and Servlet 2.5/JSP 2.1 APIs.

[root@web01 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

[root@web01 ~]# yum info -v apache-tomcat-apis
Loading "fastestmirror" plugin
Config time: 0.009
Yum version: 3.4.3
rpmdb time: 0.000
Setting up Package Sacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.globo.tech
 * extras: centos.bhs.mirrors.ovh.net
0
Hi,

What is the use of below command from eclipse project by right clicking and run as "maven build.."

what is meaning of shade why we need to give in the goal?

please advise
0
Hi,

When i right click on junit test(say ProductWeightTest.java) and run as Junit test from eclipse i keep getting popup with error

error could not create the java virtual machine error a fatal exception has occurred. program will exit



when i run individual test (checkWeightLessthan10Lb) in above test ProductWeightTest.java  i keep getting initialization error in eclipse console.

i tried changing eclise .ini entries but still getting same error. please advise
0
when i run junit test class getting initializationError Runner: Junit 4

not sure why suddenly i am getting that error and how to resolve it.

please advise
0
Hi,

I have a setter method(setBeginDate) that changed by some one from calendar date object to String object.

now i have to change my unit test to reflect that by changing to String.

articleVisibleData.setBeginDate(setDateMonthYear(30, 1, 2015));

How i edit method above so that i get String

earlier method is

            public Calendar setDateMonthYear(int day, int month, int year) {
            Calendar cal = GregorianCalendar.getInstance();
            cal.clear();
            cal.set(Calendar.DAY_OF_MONTH, day);
            cal.set(Calendar.MONTH, month);
            cal.set(Calendar.YEAR, year);
            return cal;
      }

now i am trying like below but wont work


      public String setDateMonthYear(int day, int month, int year) {
            String str="";
            str= str.concatenate(date).concatenate(month).concatenate(year)
            return str;
      }


earlier from test case i used to call like

articleVisibleData.setDate(setDateMonthYear(30, 1, 2015));

please advise
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I am a newbie JSP & Servlets.I  am trying to  use(copy)    code of one JSP page  to another JSP page.The goal is to have the   same functionality across the two pages.But it seems I am missing  implicit objects attributes  set up in previous page.How can I have previous Implicit objects displayed in my  current page?
0
I have JSP page and drop down list programatically populated.
Now, under some circumstances that dropdown should be disabled, but user should be still able to see all of it's element, but can't actually select it, something like this: https://jsfiddle.net/nenadbulatovic/6g4pmmpv/1/

Obviously as there is condition I can't just put disable next option.

This is actual part of code (drop down) where I need that.

  <div class="row-fluid">
    <div class="span3">
      <label><%=Constants.REQUIRED%>&nbsp;<c:out value="${requestScope.RESOURCES_MAP.SITE_PARENT}"/>:</label>
        <select class="selectpicker" data-width="100px" id="siteParentNameSelect" style="width:250px;margin-bottom:0px;">
          <option value=''>${requestScope.RESOURCES_MAP[SELECT]}</option>
          <c:forEach var="siteParentName" items="${siteParentNameList}">
            <option value="${(pageContext.request, siteParentName.id)}" ${siteParentName.id == '0' ? 'selected = "selected" ' : ''}> ${siteParentName.name}</option>
          </c:forEach>
        </select>
    </div>
  </div>

Open in new window


I should check if some condition like "enabledFlag" and then if it is true/false enable/disable its elements for selection.
0
Hi,

what is the difference between remote vs local ejb. When to use which one and advantages, disadvantages, practical uses of each.

I am trying below example and author choose remote here which is not clear
http://www.ejbtutorial.com/j2ee/hello-word-tutorial-for-writing-stateless-session-enterprise-java-bean-ejb
As given below i created java project to access above ejb as jar

i included above ejb jar in build path i still get compilation error while recognizing Addition class and AdditionRemote interface as attached.

please advise on how to fix i9tremoteplease advise
build.png
0

There is also helpful tutorials on BlazeMeter.com for JMeter, you don't have to use BlazeMeter but they do allow you to import your JMeter .jmx file and run tests if that is a route you want to go.

I am reading as above. I wonder what are difference between JMeter Vs BlazeMeter, advantages, disadvantages, practical uses.Please advise
0
Hi,

I am going through below link

http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html

I was not clear on DTDs and Java version relationship and which one to use in WEB.XML.

Please advise
0
Hi,

When we use batch vs regular insert in spring DAO application.
purchaseDAO.batchInsert(purchase);
please advise
0

JSP

JavaServer Pages (JSP) allow the development of dynamically generated web pages. It uses the Java programming language; JSP pages are translated into servlets at runtime, with each servlet being cached and reused until the JSP is modified. JSP allows Java code to be interleaved with static web markup content, so the resulting page can be compiled and executed on the server to deliver the content.

Top Experts In
JSP
<
Monthly
>