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

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
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
Hi,

I am new here. I was working on jsp pages and looking forward to implement a hiding function for a division based on if condition as shown below code:

<c:forEach items="${roleMapList}" var="item">
<c:if test="${item.rolemaproleid == 1 && item.rolemaproleid == 2 && item.rolemaproleid == 3}">
                           
/*  Here I have to implement code (jquery/javascript) to disable a div having an id= "hidingDiv"  */
                           
</c:if>
</c:forEach>

Could you please help me to surve for this day
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
Hi,
what are differences, advantages, disadvantages between

dao vs facade design patterns used i java and j2ee applications?
please advise
0
Hi,

I spring application context.xml why we need proxy object as below


      <bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target" ref="exampleBean"></property>
            <property name="interceptorNames">
                  <list>
                        <value>beforeAdv</value>
                  </list>
            </property>

what is the need of below property name
      <property name="interceptorNames">

where we supposed to use above property.

for @Around advise where below method is defined in API

obj=methodInvocation.proceed();
also for loggging why below method takes JointPoint as argument?
public void logBefore(JoinPoint joinPoint){


why we use
 <context:property-placeholder and jdbcTEmplate
and also
@ComponentScan
please advise
0
In spring ApplicationContext.xml why we mention scope like prototype, singleton etc as below.
            <bean id="obj" class="com.xyz.Welcome" scope="prototype"/>

which one to use which cases and what is the default value and advantages and disadvantages of each scope.
please advise
0
Hi,


spring ApplicationContext.xml  file why we alias name like below
      <alias name="student" alias="alias_stud"/>

i basically have student bean id with all its properties and additionally i have property called car as well within that(which is object has fields like model, type etc)

please advise
0
Hi,

I was  reading as below

Developing entity beans does not require a business interface; in fact, message-driven beans are the only EJBs that must implement some business interface.

from the link
http://www.javaworld.com/article/2071724/java-web-development/ejb-fundamentals-and-session-beans.html

i have not understood why enitiry beans do not require business interface whereas MDBs do.





what is Business interface and what are its uses.

When an EJB-based application needs to receive asynchronous messages from other systems, it can leverage the power and convenience of message-driven beans. Asynchronous messages between systems can be analogous to the events that are fired from a UI component to an event handler in the same JVM. For example, in the business-to-business (B2B) domain, a wholesaler could have an EJB application that uses message-driven beans to listen for purchase orders issued electronically from retailers.
how MDBs analogous to UI and same JVM?



Session beans are great at implementing business logic, processes, and workflow. For example, a StockTrader bean with buy() and sell() methods, among others, would be a good fit for a session bean.
Entity beans are the persistent data objects in an EJB application. In a stock trading application, a Stock bean with setPrice() and getPrice()methods would be an appropriate use of an entity bean. The buy() method of the previously
0
Under the facade project i have


FacadeResponse facadeResponse = new FacadeResponse();
            
            List<Report> reportNumbers = new ArrayList<Report>();
            
                  facadeResponse.setSuccess(true);
                  facadeResponse.setResponse(reportNumbers );


Report object in turn have bunch of fields like

private String reportNumber;
      
      private Calendar reportDate;



How do i set values of  so that callign web service see proper data in response.

reportNumber and reportDate within facade?

reportNumbers is not simple array list of String object where i can easily call add method.

reportDate again has Date, Time,TimeZone etc

please advise
0
Hi,

In eclipse when i expand on a project i see MAven Dependencies and target
I am trying below example
https://www.mkyong.com/spring3/spring-3-hello-world-example/
i like to know when to what is use of MAven Dependencies and target

please advise
md1.png
md2.png
0
Hi,

I am working on below spring application

https://www.mkyong.com/spring3/spring-3-hello-world-example/

My junit class shows bunch of errors LIKE

The import junit cannot be resolved

How to resolve these issues. please advise
JUNITteST.png
0
Hi,

I am trying simple spring examples like hello world


I see maven not picking latest jars like spring core (4.1.6)instead picking old jar(3.0.5) from .m2.

How to tell maven to take latest but not old jar. I wonder why it is taking old jars. Please advise
mavenjars.png
mavenjars2.png
mavenjars3.png
mavenjars4.png
mavenjars5.png
0
hi,

while importing as existing maven project i see some projects have single pom.xml some other projects have top level pom and also sub level pom.xml as well. why we need like parent pom and child pom kind of structure for some projects?
please advise
0
hi,

i wonder why and what for we use below option


eclipse preferences download repository index updates on startup


what exactly it does in .m2 folder. please advise
0
Hi,

I am trying below example
http://www.mkyong.com/spring3/spring-3-hello-world-example/

when i do mvn clean install from comand prompt getting below error

spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)


when i do internally from STS(like eclipse) editor maven clean is happening fine. While doing maven install getting below errors

COMPILATION ERROR :
[INFO] -------------------------------------------------------------
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-core\4.3.3.RELEASE\spring-core-4.3.3.RELEASE.jar; invalid LOC header (bad signature)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
error reading C:\Users\xyz\.m2\repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar; invalid END header (bad central directory offset)
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[3,35] package org.springframework.context does not exist
/C:/gpFolder/stsWorkspace/SpringDemo1_03122017/src/main/java/com/mkyong/core/App.java:[4,43] package org.springframework.context.support does not exist
how to resolve

my code is

pom.xml is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	

Open in new window

0
Hi,

I started my glassfish server.

I went to below url
http://localhost:4848/common/index.jsf
gives error like

This site can’t be reached

localhost refused to connect.
Search Google for localhost 4848 common index

how to know exact port number where server is running and admin console exact url.

please advise
0
Hi,

In eclipse i have TestWeb project with bunch of jsp and html files in eclipse. I right clicked on it and copied. Then i pasted then eclipse asked name TestWeb2 ok? i said yes. I created TestWeb2. Now when i try to run TestWeb 2 tomcat9 complains

Could not publish server configuration for Tomcat v9.0 Server at localhost.
Multiple Contexts have a path of "/TestWeb".

how to change the context name or path so that i can run TestWeb2 project as well in tomcat ?
please advise
0
Hi,

I am workign in jsp CRUD operations 0n mysql with and without prepared statements and hibernate approach. I wonder what are advanges and disadvantages and practical uses of each approach? can you please provide some sample code on each aproach to try on mysql databse preferable with primary key and foeign key kind of relationships as i am not that strong on the data modeling and relationships?
please advise
0
Hi,

My jso application giving below error


username:admin123
username:admin1
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '','01091999','tt','t@t.com','AAA')' at line 1
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)


How to resolve this.
my account.jsp is
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    %>
<!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=ISO-8859-1">
<title>Account Creation Screen</title>
</head>
<body>
	<%@include file="header.jsp" %>
	<div style="width: 300px; margin-left:auto;margin-right:auto;">
		
		<h1>Account Creation Screen</h1>
		<form action="accountCreate.jsp">
			<table>
				<tr>
					<td>			
					Name
					</td>
					<td>
					<input type="text" name="name"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					DOB
					</td>
					<td>
					<input type="text" name="dob" placeholder="Sample Format 1989-01-31"><br>
					</td>
				</tr>
				
				<tr>
					<td>
					Address
					</td>
					<td>
					<textarea type="textarea" name="address" rows=10 style="width:200px; height:100px;"></textarea><br>
					

Open in new window

0
Hi,

how to run on tomcat not jboss eap wild fly7.0. Wnhen i run the web application index.jsp it is by default starting jboss wild fly server not tomcat 8.0 . how when run as server particular jsp run tomcat8 all the time. pleas 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
>

No Top Experts for this time period. Answer questions to earn the title!