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

I have problem to display my PDF file in an existing popup window using spring framework. The workflow is when I click a button from the main page, it popups a new window (child) and showing progress status. After the file finished generating, I set the view in controller and return to jsp. However, the PDF file displays (using DefaultResourceLoader and response.flushBuffer) in the main page instead of the popup window. I want to show in popup. Anything wrong? How can I specify which window the PDF should be displayed?

Please help. Thanks.
0
Cloud Class® Course: Amazon Web Services - Basic
LVL 12
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Dynamic Form/Table from BackEnd for every entities which has CRUD operations

I'm developing a Java Web application.

I need to

1st option list the user clicked entity menu on the UI
2nd search page where user enter values for the fields and we need to publish the search results in a table

Note: the number of columns will differ from entity to entity

In either case, i need to know hoe to define a generic entity, pojo, DAO and DAOimpl, service and controller class and view jsp page

What should be the return type Object for #1, #2

How to create a generic jsp page to display the results for any entity

Please advise

Thanks
0
can any one provide an sample application for tomcat 7.x that can trigger OutOfMemory and hung threads?.
0
I am learning spring Boot framework right now, I am trying to apply i18n concept on my simple application. But whenever I run the application, the following error returned: "No message found under code 'label.welcomeMessage' for locale 'en_US'.". I have read about this issue and tried a lot before I getting here to ask but noting have worked with me.

Here is my AppClass configuration:

package com.abed.main.configuration;


import java.util.Locale;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;

@Configuration
public class AppConfig implements WebMvcConfigurer{



    @Bean
    public LocaleResolver localeResolver()
    {
        SessionLocaleResolver slr = new SessionLocaleResolver();
        slr.setDefaultLocale(Locale.US);
        return slr ; 
    }

    @Bean
    public LocaleChangeInterceptor LocaleChangeInterceptor()
    {
        LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
        lci.setParamName("lang");

Open in new window

0
language: Java

 i have one bank statement  in xls format , which i already convert into csv format in java .  and display in jsp  ,but how user can recognized the amount is debit or credit because it come in one column i.e  amount . and  after edit  form jsp it will save in database , where two different column for debit and credit .....

Problem:  In excel File : there is two column Debit Amt. and credit Amount , but the transaction will be debit or credit , but when i convert into csv file ,  it not write null on blank cell . i

 used missing policy ,
 case Cell.CELL_TYPE_BLANK:
                                                                                               
                                  data.append("***" + ",");
                                    break;

 but it work on total blank column , not a every blank cell .

Kindly guide .Thanks  in advance .
0
Hello There ,
 I am new to Spring framework , i started to learn Spring MVC framework , i am currently trying to use internationalization (i18n)and localization (i10n) and every thin is going as expected

but here is my question in my project i have just 3 JSP and i have apply the (i18n) concept on them but i am wondering what if have 100 JSP , do i have to write a code and labels for all 100 JSP or can i make my all of my JSP app internationalized  just by clicking on a link to change between languages i want ???
0
I am new to Spring MVC and I am trying to build a simple web App I am using Hibernate with Spring MVC. I am trying to implement CRUD operations in this web app, all CRUD operates properly except the update although DAO And Service Layers are working properly the problem here is about the JSP's and controllers. whenever I click update from the table it took me to the desired page to enter new book info but from the Update page when I click on update book submit button it stays on the same page and it does not call the desired controller method to take me where I want. I am talking about the last two methods.

Here is the Controller

package com.abed.controllers;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.abed.models.Book;
import com.abed.service.BookService;

@Controller

public class BookController {

    @Autowired
    BookService service;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String 

Open in new window

0
Anyone knew...i had an issue .... if i have to save the timer to the server, i'll need the JavaScript to animate and increment the timer.
Have the JavaScript periodically send the value of the timer back to the server for saving so that the user can logout and login back in from anywhere and continue their timers..how????.please explain??
0
Receiving error as follows. Please do needful.
HTTP Status 500 - Filter execution threw an exception
exception :
javax.servlet.ServletException: Filter execution threw an exception
root cause :
java.lang.Error: Unresolved compilation problems:
      The import com.opensymphony cannot be resolved
      The import com.opensymphony cannot be resolved
      The import com.opensymphony cannot be resolved
      ActionSupport cannot be resolved to a type
      ValueStack cannot be resolved to a type
      ActionContext cannot be resolved

      com.tutorialspoint.struts2.HelloWorldAction.<init>(HelloWorldAction.java:5)
      sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      java.lang.reflect.Constructor.newInstance(Unknown Source)
      java.lang.Class.newInstance(Unknown Source)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:130)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:161)
      com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150)
      com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120)
      com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:300)
      com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:400)
      com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
      …
0
I have a web application that is deployed in wildfly 12, and I need to precompile the jsp for production, in the forums I saw that jspc is not longer  supported for jboss, also y tried maven plugin with no success.

i tried using management deployment and later do the explode forn the web console but the jsp isn't compiled
Also i couldn't find a command to do it from the hot-deployment, like glassfish --precompilejsp parameter.

how to do the precompilation of the jsp in wildfly?
0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

I have a Tomcat app. Recently, I've updated the connection pool, in order to use Tomcat's jdbc-connection pool. In my Windows developing machine, everything works fine, but now that I'm trying to implement this on my Linux Server, I get this exception (see title) when ever my app tries to connect to MySQL.

I'm using "Easy Tomcat 7" which is supposed to be the same as the regular version of Tomcat, only it comes with the CPanel software.

I just need this database to be available for this app (not multiple app's).

This is my java DB class:

public class DBUtil {

static DataSource ds;
static {
    try {
        Context context = new InitialContext();
        ds = (DataSource)context.lookup("java:comp/env/jdbc/rhwebDB");
    } catch (NamingException e) {
        e.printStackTrace();
        System.out.println("DBUtil.NamingException" + e);
    } catch(Exception e) {
        System.out.println(e);
    }
}

public static Connection getConnection() throws SQLException {
    return ds.getConnection();
}

Open in new window


This is my context.xml file, which is located on myAppDirectory/META-INF folder

<?xml version="1.0" encoding="UTF-8"?>

<Context>
<Resource
    name="jdbc/rhwebDB"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    testWhileIdle="true"
    testOnBorrow="true"
    testOnReturn="false"
    validationQuery="SELECT 1"
    validationInterval="30000"
    timeBetweenEvictionRunsMillis="30000"
    maxActive="20"
    minIdle="3"
    maxIdle="15"
    maxWait="10000"
    initialSize="3"
    removeAbandonedTimeout="60"
    removeAbandoned="true"
    logAbandoned="true"
    minEvictableIdleTimeMillis="30000"
    username="dbuser"
    password="dbpassword"
    driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://127.0.0.1:3306/rhmexweb_rhweb"/>
</Context>

Open in new window


I don't use WAR files. I just upload files to my server and re-start tomcat when needed, which normally works just fine.

In case this is relevant too, Tomcat's server.xml file has this settings for this website. I've also tried adding parameter copyXML="true", with no luck so far:

<Host name="rhweb.mx" appBase="webapps">
          <Alias>www.rhweb.mx</Alias>
          <Context path="" reloadable="false" docBase="/home/rhmexweb/public_html" debug="1" />

Open in new window


Here's the full stacktrace I get when my app tries to establish a connection with MySQL:


Open in new window

0
Greetings,

I am  working on servlet  project and I  had made a jsp form in my project.  I have fetch the data in my dropdownlist using jsp code.  But the error is that when I select dropdownlist
I  want  to fetch the data in my multiple textbox according to my sql database column.

Please can you help me?
0
Will not display the image that retrieved from DB (as blob)  in Chrome ? But working fine with Firefox.
0
I downloaded a working demo but when I integrated it with the registration page made by me I am getting an error on adding a new user:

[Field error in object 'user' on field 'userProfiles': rejected value [3]; codes [typeMismatch.user.userProfiles,typeMismatch.userProfiles,typeMismatch.java.util.Set,typeMismatch]; arguments
[org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.userProfiles,userProfiles]; arguments []; default message [userProfiles]]; default message
[Failed to convert property value of type 'java.lang.String' to required type 'java.util.Set' for property 'userProfiles'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type
[com.idev.tpt.model.UserProfile] for property 'userProfiles[0]': no matching editors or conversion strategy found]]

JSP File:

<form:form id="userForm" action="newuser" modelAttribute="user">
    <form:input type="hidden" path="id" id="id" />
    <div class="form-group">
        <form:input type="text" path="firstName" id="firstName" placeholder="First Name" class="form-control input-sm" />
    </div>
    <div class="form-group">
        <form:input type="text" path="lastName" id="lastName" placeholder="Last Name" class="form-control input-sm" />
    </div>
    <div class="form-group">
        <c:choose>
            <c:when test="${edit}">
                <form:input type="text" path="ssoId" id="ssoId" placeholder="SSO ID" 

Open in new window

0
I created one application in netbeans 8.2 now i want to deploy this application in weblogic for that i created weblogic.xml but when i validate its giving me following error at the same time when i deployed as it is then in weblogic it is showing me Unable to access the selected application.,Exception in AppMerge flows' progression,Unmarshaller failed when i validate weblogic.xml its showing me below error,im using apache tom cat in server side weblogic java version is java version "1.7.0_71" where in my windows it is 1.8.0_161

Checking file:/D:/GODBFILES/NETBEANS%20PROJECTS/NetBeansProjects/EmployeeRegistration/web/WEB-INF/weblogic.xml...
schema_reference.4: Failed to read schema document 'file:/C:/Program%20Files/glassfish-4.1.1/glassfish/lib/schemas/weblogic-web-app.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. [2]
cvc-elt.1: Cannot find the declaration of element 'weblogic-web-app'. [2]
schema_reference.4: Failed to read schema document 'file:/C:/Program%20Files/glassfish-4.1.1/glassfish/lib/schemas/weblogic-web-app.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. [3]
schema_reference.4: Failed to read schema document 'file:/C:/Program%20Files/glassfish-4.1.1/glassfish/lib/schemas/weblogic-web-app.xsd', because 1) could not find the document; 2) the document could not be read; 3) the …
0
Here is my html code where i creating dynamic textbox for insert using jsp
function getinput()
{
index ++;
var singleRecord = "";
singleRecord += " Employee_id : <input type='text' READONLY name='txt_Employee_id"+index+"'value='<%=request.getParameter("employee_id")%>'>";
singleRecord += " Project_name : <input type='text' name='txt_project_name"+index+"'>";
singleRecord += "Project/Task : <input type='text' name='txt_Header"+index+"'>";
singleRecord += "Department : <input type='text' name='txt_Department"+index+"'>";
singleRecord += "Description : <input type='text' name='txt_description"+index+"'>";
<!--singleRecord+="Date : <input type='date'  name='datainsertdate"+index+"'>"; --->
singleRecord += "<hr/>";
$("#inputs").append(singleRecord);
$("#count").val(index);
}

</script>

</head>

<body background="123-slideshow\blue_background.jpg">
<form action="EmployeeVendorValidation.jsp" method="post">

   
     <br><br><br><br>    
<input type="hidden" name="count" id="count"/>



<div id="inputs">
</div>
<button type="button" onclick="getinput()" class="button button5">Add</button>

&nbsp;
<button type="submit" class="button button2">Submit</button>

jsp:

 Class.forName("oracle.jdbc.driver.OracleDriver");
          Connection con=DriverManager.getConnection("jdbc:oracle:thin:@172.18.114.213:1821:godb","xe","ex");
       PreparedStatement ps = con.prepareStatement("insert into employee_task values(?,?,?,?,?,?)"); …
0
How to delete products from shopping cart when user session ends (or Logout in ) in jsp web application.When you then add a product to your cart (not logged in) and then decide to login and go to the checkout, I now have 2 products in the basket. Is there a way to not store products in the basket when you logout?

I know that this is a cookies issue, but is there a way to remove products from the cart when logging out?

Following is code what i have tried.




product.jsp
<link href="style.css" rel="stylesheet" type="text/css" media="all" /> 
<div class="cart"> 
						<form action="#" method="post" class="last"> 
							<input type="hidden" name="cmd" value="_cart" />
							<input type="hidden" name="display" value="0" />
							<button class="w3view-cart" type="submit" name="submit" value=""><i class="fa fa-cart-arrow-down" aria-hidden="true">cart</i></button>
						</form>  
					</div>
					
						<div class="item" style="width: 30%">
										<div class="glry-w3agile-grids agileits"> 
											<div class="new-tag"><h6>20% <br>Off</h6></div>
											<a href="products4.jsp"><img src="s3.jpg" alt="img"></a>
											<div class="view-caption agileits-w3layouts">           
												<h4><a href="products4.jsp">Nylon Shuttle</a></h4>
												<p>Lorem ipsum dolor sit amet consectetur</p>
												<h5>$56</h5>
												<form action="#" method="post">
													<input type="hidden" name="cmd" value="_cart" />
													<input 

Open in new window

0
I have a jsp page using struts tag as below:
<html:form action="/actions/graphics/job/attachFile/confirm">
<html:cancel value="Cancel" styleClass="buttons"></html:cancel>
<html:submit value="Confirm"/>
</html:form>

Open in new window

     
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		ActionForward actionForward = SessionChecking.checkUserBean(mapping, request);
		if (actionForward != null)
			return actionForward;

		if (isCancelled(request))
		{
                 //do something here
                }
               //......
     }//execute

Open in new window

it works very well in production for years, now I am trying to change the looking of the button by integrating with bootstrap.
When I only changed the looking of button confirm, it looks like this:
confirm_button_only.pngat this moment, both buttons are functioning.

however, when I tried to change the looking of both buttons, it looks like this:
confirm_cancel_both.png
             <html:form action="/actions/graphics/job/attachFile/confirm">
		<button type="submit" id="cancel" name="cancel" class="btn btn-default" value="Cancel"  > Cancel</button>
		<button type = "submit" id="submit" class ="btn btn-primary" value="Confirm"> Confirm</button>
		</html:form>		

Open in new window

they both looks good, but the problem is both buttons are doing the same job, which means they both have the CONFIRM function , no more CANCEL function.

then I tried a little modification for experiment:
             <html:form action="/actions/graphics/job/attachFile/confirm">
		<button type="button" id="cancel" name="cancel" class="btn btn-default" value="Cancel"  > Cancel</button>
		<button type = "submit" id="submit" class ="btn btn-primary" value="Confirm"> Confirm</button>
		</html:form>	

Open in new window

the problem for this code is the CANCEL button does NOT work at all regardless how many time I click on it.

can anybody help me on this? all I want is just make the CANCEL button looks as big as the CONFIRM button but keep the original functioning.
I think the real question would be : how to transfer the value of CANCEL button to the HttpServletRequest such that the function isCancelled(request) can return true?
by name="cancel" ?  value="Cancel" ? or type="cancel"?
0
I am dealing with datasource in a jsp page and getting

 javax.servlet.jsp.JspException: 'dataSource' is null

what to do in case I am not having exposure to Datasource. I can't attach the code as it is confidential.
0
Get your problem seen by more experts
LVL 12
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

I am trying to convert some coldfusion code to jsp and there are some tags like cfargument,cf:loop,cf:return,cf:location.. can anybody tell me what to use in place of these tags in jsp?
0
Hi, I've a Struts 1.x web Application and we have new enhancement we need to redirect to some other application for authenticating and  authorization. In detail, we need to remove our app login page and need to redirect to some other website for login page. I'm using response.sendRedirect(https://xxx.com) and its redirecting to other website but before we display our home page we need to validate their response by calling two times their website. My question is how can I get their website response paramers to validate. Please help us. Thanks!
0
Hi,

I want help on getting data from sql server to Java/JSP page.  I am new to Java/jsp, and need some help with some sample code.

I have a stored proc. [getemployee] which is retrieving FirstName,LastName,EmailAddress. I need to use this stored proc on Java/jsp to show details on jsp page.

Thank you so much for help!
0
I am using jsp tag library based on com.jenkov.prizetag . how can I make it keyboard accessible
0
If i have a rest controller in spring boot how can I validate the contract that comes in if certain values of the parameters need to have certain values??? ANy code examples are appreciated!
0
What is the best technology to create a new shopping website? Like JSP, bootstrap, aspx, angular, PHP etc…
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!