Menu
  • HOME
  • TAGS

Unable to include servlet response by using requestDispathser

java,jsp,servlets,requestdispatcher

In your IncludeServlet instead of overriding doGet method override doPost , Since Post request is coming from HTML protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // do Whatever you want to do . } Update: Also write res.setContentType("text/html"); in both servlet so that your html written in...

Is it not possible to directly invoke session.getAttribute() with EL?

jsp,el,session-scope

My question is why doesn't session.getAttribute() work when using the JSTL tag? The correct way of fetching a session attribute in a jsp via EL is <c:out value='${sessionScope.EMAIL}'/> You are messing up the JSTL & scriptlet code, you can try email: <%= session.getAttribute("EMAIL") %> ...

JSP - issue with custom Taglib

java,jsp

Hi all inbuilt tag already handles the expression language. Just change your code as mentioned below and it will work fine. public class TestTaglib extends TagSupport { private String testCode; public int doStartTag() throws JspException { try { JspWriter out = pageContext.getOut(); //doing some conversion with testCode String value =...

I want to call a Servlet as a very first file

java,jsp,servlets

Configure your servlet URLpattern as <welcome-file> in web.xml file located in WEB-INF folder of webapp like below: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>ProjectName</display-name> <welcome-file-list>...

struts dialog box not taking jsp scriplet

java,jquery,jsp,struts2,ognl

You can't mix Scriptlets (<% %> , that you shouldn't use at all) with Struts tags (or Struts2-jQuery tags). Also you don't need to: with an Iterator, you get an IteratorStatus object, that can be used as a counter: <s:iterator value="campaignList" status="currRow"> <sj:dialog id="DivQuestionAnswer%{#currRow.count}" ... > Note: #currRow.count is 1-based,...

Can you make JSP to crash on undeclared variables?

java,jsp

The problem why it's slow when accessing undeclared variables is that the ELResolvers dig very deep to try and find the variable. See http://grepcode.com/file/repo1.maven.org/maven2/org.apache.tomcat/tomcat-jsp-api/8.0.15/javax/servlet/jsp/el/ScopedAttributeELResolver.java#58 Many ClassNotFoundExceptions are thrown when trying alot of non declared variables which takes a lot of time. One way to solve this is to write a...

How to multiply values from different coloumn in jsp servlet

jsp,servlets

Try below.... <% int price = resultSet.getInt("price"); int qty = resultSet.getInt("quqntity"); int value = price * qty; %> Result Value (price * quantity) = <% = value %> Please let me know if you have any further queries...

Using Hibernate on JSP

java,hibernate,jsp

To me it seems like something is missing , Not that an expert of JSP, but I see that you don't import stuff around the hibernate package. You do seem to import "java.util.*" - but what about the hibernate packages? Where do you import them? In addition, do you see...

How to get current jsp file path in war?

java,jsp

This will be implementation dependent, but since many implementation use Jasper, it may well be more portable than you think. Of course, portability may not be an issue. But the simple case is that you take the full qualified class name of "this" from within the JSP, and from that...

`null` result from request in servlets

java,jsp,servlets

Because you are not submitting your form to server or not passing any value in url, instead you are clicking on link, which will redirect it to your link. <body> <form action="display.jsp"> // added action <input type="text" name="uname"> <input type="text" name="pwd"> <button type="submit">Link</button> // added submit button </form> </body> For...

Login page filter problems

jsp,servlets,servlet-filters

In web.xml you can make entry which will accept a URL-mapping and whenever you will call that URL your filter will intercept that and you can navigate your request to any page.

How to display text in browsers tab bar in a javaserver page [closed]

html,jsp,browser,text,tabs

Browser tabs display the FavIcon and the <title> of the page. You can't really display multiple lines in a browser tab, though you could separate information you want to display in it with a -, which is pretty common practice. For example: <html> <head> <title>My Title - Awesome Web Page</title>...

Set default value for struts 2 autocompleter

jquery,jsp,struts2,struts2-jquery,struts2-jquery-plugin

You should use the value attribute as suggested by @Choatech: value false false String "Preset the value of input element." The value specified, however, should be one of the keys listed in your cityList, not some random value. If the value you want to use is an header one, like...

Need to add elements of an array to a variable of JavaScript in JSP

javascript,arrays,jsp,jstl

First of all, in your code for two arrays you don't want to have square brackets enclosed in the quotation marks. This will make your whole arrays result and result2 to be a Strings. Second, closing bracket is missing for results, opening bracket is missing for results2. Third, you cannot...

Why ${!blabla.blibli} returns true in JSTL even if blabla doesn't exist?

java,jsp,jstl

JSP EL is NULL friendly, if given attribute is not found or expression returns null, it doesn’t throw any exception. For arithmetic operations, EL treats null as 0 and for logical operations, EL treats null as false. So when you are trying "!" for the variable which is not found...

Spring MVC link with .jsp/.jsp suffix returns 404

java,spring,jsp,spring-mvc

The most likely cause of your issue is that the *.jsp and *.jspx extensions are normally handled by the container. If you for example checkout tomcat's conf/web.xml you'll notice a configuration <servlet> <servlet-name>jsp</servlet-name> <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.jsp</url-pattern> <url-pattern>*.jspx</url-pattern> </servlet-mapping>...

Servlet to jsp on button click - whats the error?

java,jsp,servlets

Tried out the code in a separate jsp, picking up sections and pasting them, removing extra div's. Seemed to make it work.

Sending text file to client through Spring MVC web application

java,spring,jsp,spring-mvc,servlets

It is not possible to redirect to another page when returning file as file itself is http response. Very good explanation is here: Spring - download file and redirect

Form submit portlet with Spring MVC

java,jsp,spring-mvc,liferay,portlet

Which version of Liferay you are using? if it is > 6.2 GA1 Then in your liferay-portlet.xml file, please add this attribute and recompile and test again. <requires-namespaced-parameters>false</requires-namespaced-parameters> Liferay adds namespace to the request parameters by default. You need to disable it. ...

HTTP Status 500 - Servlet execution threw an exception (java.lang.ClassNotFoundException)

java,jsp,servlets,twitter

If you are using pom.xml, please include this dependency: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>3.10-FINAL</version> </dependency> Or include this jar in your classpath : poi-ooxml-schemas-3.10-FINAL.jar...

on clicking pass value of anchor tag to another file

java,html,jsp

I found the solution for my own question. I did this by passing the value in anchor tag itself. <a href="demo.jsp?id1=<%=rs.getString(2) %>">><%=rs.getString(1)%></a> and then fetching it in demo.jsp by using String var=request.getParameter("id1"); ...

Persistent authentication filter logging in; not propagating to JSP

jsp,java-ee,jstl,struts,servlet-filters

As it turns out, the filter that I've set up for persistent authentication appears to only run when a Struts action is invoked; as such, it wasn't running on the index page of my site (among other pages), but in my case was instead authenticating when an AJAX call to...

Dynamic attributes in a jsp tag

java,jsp

You will have to enable dynamic attributes in your TLD, like so: <tag> ... <dynamic-attributes>true</dynamic-attributes> </tag> And then have your tag handler class implement the DynamicAttributes interface: public class DynamicAttributesTag extends SimpleTagSupport implements DynamicAttributes { ... public void setDynamicAttribute(String uri, String localName, Object value) throws JspException { // This gets...

How to compile and run a JSP Beans project using Eclipse

java,html,eclipse,jsp

The problem is the difference between you input name and the setter of UserData, please try to modify the index.html as: <form action="saveName.jsp" method="post"> What is your name? <input type="text" name="userName" size="20"> <br> What is your email address? <input type="text" name="userEmail" size="20"> <br> What is your age? <input type="text" name="userAge"...

set focus to next input element after jsf's change value listener

javascript,jsp,jsf

finally i found the solution. in my Value Change Listener. i added this statement at the end. if(event.getComponent().getId().equalsIgnoreCase("COMPONENT ID FIRST")){ String jsStatement = "document.getElementById(\'" + ("COMPONENT ID SECOND")+ "\').focus();"; SESSIONCLASS.setBodyOnload(jsStatement); } in the above code "COMPONENT ID FIRST" is the current component where your value change listener is triggered and...

How to get specific values from select menu and use her in mysql query?

java,mysql,jsp

Instead of using a Statement, you should use a PreparedStatement What you'll need to do is send the obiekty.id in a request to your server (more info here) and then put it into the Prepared statement as follows: try (PreparedStatement st = conn.prepareStatement(query)) { st.setLong(1, obiekty.id); ResultSet rs = st.executeQuery();...

How to pass data from page to Portlet class through AJAX call?

ajax,jsp,liferay,portlet

I recommend to use liferay's <portlet:resourceURL var="resourceURL"> </portlet:resourceURL> with AlloyUI instead of using simple xmlhttp function. Change required namespace parameter in your liferay-portlet.xml <requires-namespaced-parameters>false</requires-namespaced-parameters> Add following import <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> <portlet:defineObjects /> Change the url to below url += '?cache=' + nocache + '&<portlet:namespace/>nRows=' + numberOfRows; Please...

HTTP Status 500 - java.lang.LinkageError - Servlets

java,jsp,maven,servlets,web.xml

You probably need <scope>provided</scope> on org.apache.tomcat in your pom.xml

Why Spring doesn't load index.html as welcome file

java,jsp

You may have to add a request mapping something like this. @RequestMapping("/index") public ModelAndView getIndexPage(Model model){ return new ModelAndView("index", "test", model); } ...

Vector : References to generic type Vector should be parameterized

jsp,generics,vector

I don't think so these warnings would hang your IDE, these are harmless. And also it is always a best practice to specify the type for generics like Vectar<Object> or Vectar<String> or List<String> or ArrayList<String> etc and not use raw types. Please read from updated sources and books. It is...

when is servlet response committed or flushed?

java,jsp,servlets,forward,requestdispatcher

Calling flush() on the PrintWritercommits the response. forward method allows one servlet to do preliminary processing of a request and another resource to generate the response. You can have many out.write statements before forwarding but you can't call flush before forwarding. like PrintWriter out = response.getWriter(); out.write("forwarding...\n"); rd.forward(request, response); //this...

Intellij web application on tomcat server shows http://localhost:8080/index.jsp instead of http://localhost:8080/myapp/index.jsp

java,jsp,tomcat,servlets,intellij-idea

You can enter your application URL in the 'Edit Connfiguration' of your tomcat server. Click on Edit Configuration Enter you application URL in the start up page Note:- Most probably above solution will work, if it doesn't then you might need to change the application context to '\myApp' in deployment...

Getting checkboxes check state

java,jsp

It seems that selected checkbox values are not being passed to the servlet. Hence you get array as null here, String[] chkDisperse = request.getParameterValues("chkDisperse");. And you end up with NPE at this line: if (chkDisperse[i] == null) Make sure that the checkbox are properly enclosed within the form tag. In...

Radio button group name

java,jsp

The simplest way is to save the number of items in a hidden input say itemsNumber and use a for loop to get the actual values of the parameters: int itemsNumber=Integer.parseInt(request.getParameter("itemsNumber")); for(int i=1;i<=itemsNumber;i++){ String cat=request.getParameter("rdCat_"+i); //then you can do processing with the above value } ...

viewResolver with more folders inside of WEB-INF/jsp is not working in spring

java,spring,jsp,spring-mvc

Say you have a jsp test.jsp under /WEB-INF/jsp/reports From your controller return @RequestMapping("/helloWorld") public String helloWorld(Model model) { model.addAttribute("message", "Hello World!"); return "reports/test"; } ...

Java Struts2 (Action class not found)

java,xml,jsp,struts2

Struts2 XML configuration provider cannot load the action class. This class com.tutorialspoint.struts2.HelloWorldAction is not available on the classpath or corrupted. The version are you using is too old, and you need to recreate the project and update version information in xml configuration files struts.xml, web.xml. See How To Create A...

Show and hide select input which is created dynamically

jquery,jsp,show-hide

One option is to use next. Since next refers to next sibling just get the parents sibling like so: if($(this).is(":checked")) { $(this).parent().parent().next().show(); } else { $(this).parent().parent().next().hide(); } ...

JSP form sending data including files in servlet

java,jsp,servlets,post,get

Form: <form id="uploadForm" name="uploadForm" action="UploadServlet" method="post" enctype="multipart/form-data"> user:<input type="text" name="user"/> img<input type="file" name="image"/> </form> You can still get both with a post request: protected void doPost(HttpServletRequest request, HttpServletResponse response) { List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request); InputStream fileContent = null; String user = ""; for (FileItem item : items) {...

Error while including jsp with angular inside non angular jsp

javascript,angularjs,jsp

A.jsp <div ng-app="AApp"> <script type="text/javascript" src="<%=webroot%>/js/angular.min.js"> </script> <script type="text/javascript" src="<%=webroot%>/js/angular-sanitize.js"> </script> <link rel="stylesheet" href="css/A.css"> <script type="text/javascript" src="AApp.js"></script> <script type="text/javascript" src="ACtrl.js"></script> <div ng-controller="ACtrl"> <h1 class="a-title">{{X}} {{Y}}</h1> </div> </div> and...

Spring passing ModelMap model attributes to JSP

java,spring,jsp

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> When you look at your header you will notice a <!DOCYPE line which points to a really old version of a web app 2.3 this disables EL. To fix simply remove that line....

Servlet path is not included in

jsp,url,servlets,jstl

The <c:url> does indeed not take servlet path into account. That's your own responsibility. The <c:url> only takes HttpServletRequest#getContextPath() into account. Either hardcode yourself: <c:url value="/web/browse" /> Or inline result of HttpServletRequest#getServletPath(): <c:url value="${pageContext.request.servletPath}/browse" /> Or if you're forwarding, inline result of RequestDispatcher#FORWARD_SERVLET_PATH: <c:url value="${requestScope['javax.servlet.forward.servlet_path']}/browse" /> Wrap if necessary in...

loop thru divs in jsp

jquery,html,css,jsp

Why not simply take the same loop and replace the tr with your div? <c:forEach items="${listArtists}" var="artist"> <div class="col-md-4 col-sm-6 portfolio-item"> <a href="#portfolioModal1" class="portfolio-link" data-toggle="modal"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fa fa-plus fa-3x"></i> </div> </div> <img src="/img/artistphotos/${artist.photo}" class="img-responsive" alt=""> </a> <div class="portfolio-caption">...

Looping Arraylist of Arrays java

java,arrays,jsp,arraylist,javabeans

Something is wrong. In your listar method, you are returning a ArrayList . This ArrayListcontains obejcts of type String[]. You are capturing this output in a ArrayList<EventosBean>, which expects objects of type EventosBean. If you are looking to print content of the String[] added in listar returned ArrayList on JSP,...

how to link external js file in jsp

javascript,jsp

The below line fixed my problem: <script src="<%request.getContextPath()%>/js/validation.js"></script> ...

How to open a new page when button is clicked on

java,html,jsp,servlets,web-applications

You can send the request from one jsp to another. Lets say after the index.jsp you want to go to login.jsp when the button is pressed.Then create a form like this: <form action="login.jsp"> <input name="username" type="text"><br> <input name="password" type="password"> <input type="Submit" value="Login"> </form> Now in the login.jsp you can get...

how to return two lists from controller class in spring mvc

java,hibernate,jsp,spring-mvc,tiles

Why do you want to return only a list, use map instead. In your controller you can use, Map mp = new HashMap(); mp.put("list1", lst1); mp.put("list2", lst2); return mp; in your jsp, you can iterate the map, for (Map.Entry<> entry : mp.entrySet()) { String listKey = entry.getKey(); List<> childLst =...

Why is my Set variable throwing error when doing a many-many query?

java,spring,hibernate,jsp,spring-mvc

EDIT: In order to have a Many-to-Many mapping between the two entities you have to specify this mapping in the two sides of the relation, and that's what you are missing here because you haven't declared a collection of CustomerCategory in your Advertisement class so you have to add it,...

How to get attribute from this request?

java,jsp

Why this isn't working You are submitting your form by AJAX and as we know AJAX is meant so that whole page doesn't get refreshed. Only a specific part of the page is refreshed. Now your page creates an Ajax request which goes to servlet and servlet forwards that request...

How to keep a variable in the URL when using Spring LocaleChangeInterceptor

java,spring,jsp,spring-mvc,internationalization

Do you mean you clicked a link with "http://xxx?lang=it"? If so, you should handle by yourself. eg. you could add a data-lang attribute, by that, add current href, like that: location.href = location.href + $("xx").data("lang");

Remove prefix and suffix of page url in spring MVC

java,spring,jsp,spring-mvc

Use Spring MVC InternalResourceViewResolver by adding this in spring configuration file: <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/pages/"></property> <property name="suffix" value=".jsp"></property> </bean> and only return "home" in the controller In your annotation-driven configuration the InternalResourceViewResolver should be set in the configuration class which extends WebMvcConfigurerAdapter like...

Ajax response doesn't display in JSP page

java,jquery,ajax,jsp,servlets

I figure out a way. I put replace "submit" type to "button". Now working perfectly. Thank you for your Time.

Print and println aren't executed in the same time

java,jsp,servlets,printing,println

This is related to the fact you never terminate the line. This is either something to do with java not flushing, or to do with the log handler waiting until the end of line before writing to the log. Add a final System.out.println() or System.out.print('\n') at the end to fix...

Session attribute is null at first load

java,jsp,servlets

First configure servlet as welcome file in web.xml. If web.xml not present than create it manually inside WEB-INF folder and put below content inside it. <welcome-file-list> <welcome-file>foo</welcome-file> </welcome-file-list> than in your servlet dispatch request to your jsp lets say your jsp name is index.jsp than your servlet code would be...

How to bypass signle quote error in javascript?

javascript,jsp,jstl

you can wrap the single quote with double quote, like: var locations = [ [ "Alex's loc", '37.9908372', ] ]; ...

Username and password validation from database to jsp view page

java,javascript,jsp,servlets

You can use a <span> element where you show your error message that you get from your servlet request, here's the JSP page: <form id="loginform" class="form-horizontal" name="myForm" method="POST" action="ValidateLoginServlet2.do" onSubmit="return validateLogin()"> <input type="text" class="form-control" name="uname" placeholder="username"> <input id="login-password" type="password" class="form-control" name="pwd" placeholder="password"> <input type="submit" value="Login" href="#" class="btn btn-success" />...

java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string

java,oracle,jsp

Remove to_timestamp from your query, because your parameter is allready a timestamp: PreparedStatement pst=con.prepareStatement("Select * from TBLTENDERS where TSTATUSDATE between ? and ?"); ...

How to exclude one textbox from the others that are using isNumeric validation with jQuery?

jquery,jsp

You need to loop all the textboxes Take a look of jquery each function here. $('input[type="text"]').each(function(){ if ($(this).attr("id") !== 'specialTextBox') { if(!$.isNumeric($(this).val())) { alert("All the text boxes must have numeric values!"); return false; } } }); ...

property nth-child seems not working in JSP CSS

css,css3,jsp

the problem is you're not closing tr tags change this: <tr> <td> <% out.print(result.getString(1)); %> </td> <td> <% out.print(result.getString(2)); %> </td> <tr> to: <tr> <td> <% out.print(result.getString(1)); %> </td> <td> <% out.print(result.getString(2)); %> </td> </tr> ...

How to use button instead input, style input?

css,forms,jsp,servlets,post

jsp form button instead of input: <button type="submit" id="submitRegInput" name="reg"> <img src="images/okBtn.png"/> </button> and css: #submitRegInput { background: no-repeat url(../images/okBtn.png) 0 0; border: none; } ...

need a javascript function that reads dynamic check box id on jsp

java,javascript,jsp

Try this function getCheckedItems(checkboxName) { var checkboxes = document.querySelectorAll('input[name="'+checkboxName+'"]:checked'), values = []; Array.prototype.forEach.call(checkboxes, function(el) { values.push(el.value); }); return values; } You can call this function and pass the name of the checkbox, you can dynamically bind the onclick function to the button and provide the dynamic name you created while...

[Ljava.lang.Object; cannot be cast to List from a request SQL

java,jsp,java-ee

The error and the line it's occurring on mean that your Query is returning a List<Object[]> - the line that's throwing the error is the first place you actually try and use a value from the List which you downcast. You're getting an array from your query because your SELECT...

Can't insert or update record to database jsp

java,jsp,jdbc

Problem for the below part PreparedStatement preparedStatement = connection.prepareStatement("update survey_data_27 set uname=?, p1q1=?, p1q2=?" + "where survey_id=?"); there are total 4 variables but your code is setting 6 variables(below is your code) // Parameters start with 1 preparedStatement.setString(1, first.getuname()); preparedStatement.setString(2, first.getp1q1()); preparedStatement.setString(3, first.getp1q2()); preparedStatement.setString(4, first.getp1q3()); preparedStatement.setString(5, first.getp1q4());...

Requested Resource is not available error

java,jsp,servlets,twitter4j

In your jsp file form action, Replace <form action="ServletValues.java" method="get"> With <form action="TwitterServlet" method="get"> Since in your web.xml your servlet mapping pattern is TwitterServlet for the Servlet class that you intend to call. Also in your servlet you are just printing to System.out while you should write into the reponse...

Open a properties file from a class in a Dynamic Web Project

java,eclipse,jsp,properties-file

You can put this propertie file within your java package for example com/test and use following: getClass().getResourceAsStream( "com/test/myfile.propertie"); Hope it helps....

Ajax url parameter issue

jquery,ajax,jsp,spring-mvc

You can use: ${pageContext.request.contextPath} by specifying the url as, url : "${pageContext.request.contextPath}/createtask/"+todoid, ...

Initialize class with constructor in

jsp,servlets,usebean

No. Either use <jsp:setProperty>, <jsp:useBean id="someId" class="mypackage.A" scope="page"> <jsp:setProperty name="someId" property="request" value="${pageContext.request}" /> </jsp:useBean> or use a normal servlet: request.setAttribute("someId", new A(request)); It's by the way surprising that you tagged [servlets] on the question while that's usually not to be used together with <jsp:useBean> as those two approaches of managing...

MySQLSyntaxErrorException in SQL syntax

java,mysql,jsp,mysql-connector

Change ResultSet rs = selectUser.executeQuery(query); to ResultSet rs = selectUser.executeQuery(); when you already prepared the statement in connection.prepareStatement(query); then why to pass the query again in selectUser.executeQuery(query);...

PropertyNotFoundException in jsp

java,jsp

The name of your getter & setter is wrong. By convention it must be: public Integer getSurvey_id() { return survey_id; } public void setSurvey_id(Integer survey_id) { this.survey_id=survey_id; } ...

Why paging query does not work

java,jsp,java-ee,servlets,jdbc

when you Click Page connection,Num is null

How to trigger a doGet before displaying a jsp page

jsp,java-ee,web.xml

You cannot do that, at least without Javascript. A ServletResponse can do only one thing : either return csv data, or return an HTML page. You absolutely need 2 different requests (be them simple normal requests or javascript one) : first to download a csv file, second to display the...

Onchange in Struts2 textfield

java,javascript,jquery,jsp,struts2

Try onkeyup, it will call JavaScript when key up is performed: <s:textfield label="Search" name="keyword" id="keyword" onkeyup="search()"/> JS Bin demo function myFunction() { var x = document.getElementById("searchText").value; alert(x); } <input type="text" id="searchText" onkeyup="myFunction()"> ...

Restriction on number of opened tabs

javascript,jsp,web,struts2,browser-tab

You can't restrict the user from opening a new tab. (This reminds me the old pop-ups with no buttons, no address bar, but still responding to backspace and other events) You can however make your app recognize the attempt of opening a third tab, and load a different result like...

How to open a link given on jsp in browser

java,jsp

It sounds like you forgot to add scheme (http) in the beginning of the URL. This would make it a relative link and be appended to your current address. If you do not know the scheme (http or https) you can start with // instead, and scheme will be inherited...

Javax JCR Node getProperties and Titles

java,swing,jsp,nodes,jcr

I am not sure but you can try getName() method because Property interface is subinterface of Item interface. You can try like below : while(pi.hasNext()) { Property p = pi.nextProperty(); String name = p.getName(); String val = p.getString(); } ...

How to show columns from different table in TABLE FORM

java,mysql,jsp

use mysql code as SELECT obiekty.nazwa, obiekty.adres, dzien, odKtorej, doKtorej FROM termin INNER JOIN obiekty ON termin.idObiekt = obiekty.idObiekt; for it to match the getString() in your controller....

Chinese characters in properties files are not properly decoded [duplicate]

java,spring,jsp,encoding

The problem is that the java propertie files are/must/should been encoded in ´ISO-8859-1´ (Latin-1) by default. Thats an Java requirement. To overcome this you can go two ways: escape the not Latin-1 charachters by utf-8 sequences in the property file: back=Zur\u00EF\u00BF\u00BDck (german word ("Zurück") with some none Latin-1 charachters) or...

unable to validate username and password from DB in jsp login form

java,jsp

replace these 2 lines statement.setString(13, username); statement.setString(14, password); with statement.setString(1, username); statement.setString(2, password); ...

html form action not working when using eclipse

java,eclipse,jsp,servlets

Try to delete the comment // @WebServlet("/hello"), and put @WebServlet("/hello"). Stop the server, refresh and if its necessary clean it. And re - launch again. And take a look if the web.xml the welcome file list is correctly, because is the file which launch always.

After redirect code still executing from previos page

java,jsp,servlets

The sendRedirect() method does not halt the execution of your method. You should either branch your code in such a way that the call to sendRedirect() is the last statement in your method or explicitly call return; after calling sendRedirect().

How to style div with jQuery?

javascript,jquery,css,jsp

Why not simply use the ternary operator? No need for jQuery here... <c:forEach items="${list}" var="item"> <div class="block" id="${item.id}" style="background: ${item.num==0?'black':'white'}"></div> </c:forEach> Update If you want to do it correctly, try to avoid inline styles and add a css class instead. So you can define your styles easily in a separate...

Can't refresh page and hold selected value on jsp page

javascript,jquery,jsp

First of all, put your select inside a form. So that when you submit it during refresh you can get the value it was holding with String selectedObiekt=request.getParameter("obiekt"). Then modify your option to read <option value="<%=obiekt.idObiekt%>" <%= ((Integer.toString(obiekt.idObiekt)).equals(selectedObiekt))?"selected":""%>><%=obiekt.nazwa%> <%=obiekt.adres%></option> ...

How to make a youtube link as embed?

java,jsp,substring

You can use the replace() method: <% out.print(url.replace("watch?v=", "embed/")); %> ...

Jsp list output [email protected]?

jsp,spring-mvc,spring-boot

There are two things I see wrong. First if your code is really as posted and not a typo, than you should note that you don't print anything inside a loop as you just iterate and never do anything with the user variable The following <c:forEach items = "${tweets}" var="user"...

adding parts of a javabean together

java,jsp,javabeans

If I understood your question then I you just need this: public static void main(String[] args) { System.out.println("Sum Of Average:: " + new Average().getSumOfAverage()); } private double getSumOfAverage() { return getPart1Average() + getPart2Average() + getPart3Average(); // call all required method here } Let me know if this is not what...

Struts2 jqGrid DatePicker in Column Filter

jquery,jsp,struts2,jqgrid,datepicker

I figured out the solution: Step 1: Add datepicker javascript to head tag... after the sj:head tag. <script type="text/javascript" src="javascript/jquery.ui.datepicker.min.js"></script> Step 2: Create a function that will be called from the sjg:gridColumn tag. searchDatePick=function(element) { $(element).datepicker(); }; Step 3: Add the searchoption property to your sjg:gridColumn tag. Reference the variable...

unable to pass two lits to the jsp using apachi tiles

hibernate,jsp,spring-mvc,tiles

You're adding the attributes and sending redirect. It will lose all the informations that you set. If you redirect to the page it will show it right. Example: if(userExists!=0){ model.addAttribute("Maintabs",new Maintab()); model.addAttribute("MaintabsList",loginService.listMaintabs()); model.addAttribute("Subtabs",new Subtab()); model.addAttribute("SubtabsList",loginService.listSubtab(userExists)); return "successPage"; }else{ model.addAttribute("error", "ERROR : invaliduser !,Please Try Again!"); return "loginform"; } If you...

reset value of all dropdowns in the page

java,javascript,ajax,jsp

I'm not familiar with Java, but in your javascript you could try call the function updateTableNameByCoverage inside updateCoverageBySubType. Something like: function updateCoverageBySubType(subLob, rmcCoverageName) { new Ajax.Updater(rmcCoverageName, 'servlet/LookupCoverageNameBySubLob', { method: 'post', parameters: { subLob: subLob.value } }); updateTableNameByCoverage('Please Select: ','rmcTableName'); } ...

AJAX call to Servlet Google App Engine (GAE)

java,ajax,jsp,google-app-engine,servlets

You cannot redirect using Ajax. That's the point of Ajax – it's asynchronous, separate from the "main thread". If you want to simply redirect either: Redirect in the Java code after doing some processing Have a link in the HTML – <a href="/register">Register!</a> If you definitely want to use JavaScript...

JSP EL not working - javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String

jsp,el

I have tried similar code. Just add public keyword in your User class like below: public class User { private long id; private String name; private String age; //Geters & Setters } Add isELIgnored="false" in <%@ page %> directive....

How to access application data in a session .jsp file

java,html,jsp,session,user

Set them as a session attributes: public void doGet(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); session.setAttribute("myVariable", variableValue); } Use some tag library like JSTL to access attributes sent from servlet instead of using scriptlets. In case of JSTL use out to print value of your variable: <c:out value="${myVariable}"...

How to persist form bean object value to retreive it later in Struts 1

java,jsp,struts,struts-1

Okay!!. First dont use Scriptlet tags thats bad practice. Since you are using Struts1.x struts supports Select tag with their Tag library. Below is the example code fragments to use dorpdown. <html:select property="langType"> <html:optionsCollection property="dropDownList" value="key" label="value" /> </html:select> Create a memeber element 'langType' type List or Map in your...

Get JSP output within Servlet in AEM

java,jsp,servlets,cq5,aem

First off - based on your description it sounds like you want to use requestDispatcher.include and not requestDispatcher.forward. Concerning the inclusion of the response content, the response which you pass into a requestDispatcher.include call could be an object of your own creation which would write its output to a string...