I'm trying t learn Spring MVC and my project is buid a jsp form input a product
I added all jar jstl lib, and here is my taglib
<%#taglib uri="http://www.springframework.org/tags/form" prefix="f"%>
<%#taglib uri="http://www.springframework.org/tags" prefix="s"%>
Here is my form appears bug
`<f:form action ="insertProduct.htm" method="GET" commandName="newProduct">
<table border ="1" cellpadding="2" cellspacing="2">
<tr>
<td>Product ID</td>
<td><f:input path="productId"/></td>
</tr>
<tr>
<td>Product Name</td>
<td><f:input path="productName"/></td>
</tr>
<tr>
<td>Price</td>
<td><f:input path="price"/></td>
</tr>
<tr>
<td>Description</td>
<td><f:input path="description"/><td>
</tr>
<tr>
<td>Status</td>
<td>
<f:select path="status">
<f:option value="true" label="Active"/>
<f:option value="false" label="Inactive"/>
</f:select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="Insert"/>
<input type="reset" value="Reset"/>
<input type="button" value="Back" onclick="history.go(-1)"/>
</td>
</tr>
</table>
</f:form>`
But i cant fix my bug. Please help me :(
Related
I need to Generate PDF report in Java. Earlier when i use Cold Fusion it was easier to export html to PDF, is there any way to convert the html to pdf in JAVA.
I tried JSPDF javascript method to convert this page but that doesn't works.
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>View JTC</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet"
type="text/css" />
<link href="assets/css/style.css" rel="stylesheet" type="text/css" />
<%
if (session.getAttribute("empid") == null) {
response.sendRedirect("index.jsp?message=Session Expired!!");
}
session.setAttribute("cpage", "production");
%>
<jsp:include page="navigationMenu.jsp" />
</head>
<body>
<section class="container-fluid">
<table class="table table-bordered">
<tr>
<th style="width:30%;vertical-align:middle;text-align:center;">logo</th>
<th colspan="2" style="text-align:center;width:70%">Denholm Yam Contracting Comapany L.L.C</th>
</tr>
<tr>
<th rowspan="2" style="text-align:center;vertical-align:middle;">Job Travel Card</th>
<th style="width:10%;">JTC No:</th>
<th></th>
</tr>
<tr>
<th>Date</th>
<th></th>
</tr>
</table>
<table class="table table-bordered">
<tr >
<td style="width:10%;text-align:left;">Project Number</td>
<td style="width:15%;text-align:left;" colspan="2"></td>
<td style="width:10%;text-align:left;">Unit No. / Tag No.</td>
<td style="width:15%;text-align:left;" colspan="4"></td>
</tr>
<tr>
<td>Area Number</td>
<td colspan="2"></td>
<td>Material Class</td>
<td colspan="4"></td>
</tr>
<tr>
<td style="width:15%;text-align:left;">Drawing No: / ISO Number</td>
<td style="width:15%;text-align:left;"></td>
<td style="width:15%;text-align:left;">JC No:</td>
<td style="width:15%;text-align:left;"></td>
<td style="width:10%;text-align:left;">Sheet No</td>
<td style="width:15%;text-align:left;"></td>
<td style="width:10%;text-align:left;">Rev. No.</td>
<td style="width:15%;text-align:left;"></td>
</tr>
<tr>
<td style="width:15%;text-align:left;">Item Description</td>
<td style="width:15%;text-align:left;" colspan="2"></td>
<td style="width:15%;text-align:left;">ITP Stage Nos.</td>
<td style="width:15%;text-align:left;" colspan="4"></td>
</tr>
</table>
<!-- Fitup data -->
<table class="table table-bordered">
<tr>
<th rowspan="12" style="text-align:center;vertical-align:middle;">
<span class="verticaltext">
Fabrication Assembly Fit-Up
</span>
</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Weld/joint No</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Item/Position No.</th>
<th colspan="2">Material Spec Grade</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Size</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Thickness</th>
<th colspan="2">Heat/Plate/TestNo</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Welder No. for tracking</th>
<th colspan="2">Fitup Result</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2">Date</th>
<th style="text-align:center;vertical-align:middle;" rowspan="2" >Sign</th>
</tr>
<tr>
<th>Material 1</th>
<th>Material 2</th>
<th>Material 1</th>
<th>Material 2</th>
<th>Accept</th>
<th>Reject</th>
</tr>
<c:forEach begin="1" var="xx" end="10">
<tr>
<c:if test="${xx==1}">
</c:if>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</c:forEach>
<tr>
<td colspan="4">Name & Signature of fabrication foreman</td>
<td colspan="3">Released to</td>
<td colspan="2">
<input type="checkbox">
QC/NDE/DIM.
</td>
<td colspan="1">
<input type="checkbox">
Welding
</td>
<td colspan="4">
<input type="checkbox">
Fabrication/Assembly
</td>
</tr>
<tr>
<td colspan="7">Date</td>
<td colspan="7">Date</td>
</tr>
</table>
<!-- welding data -->
<table class="table table-bordered">
<tr>
<th rowspan="13" style="text-align:center;vertical-align:middle;">
<span class="verticaltext">
Welding Details
</span>
</th>
<th style="text-align:center;vertical-align:middle;" rowspan="3">Joint No</th>
<th style="text-align:center;vertical-align:middle;" rowspan="3">WPS No.</th>
<th colspan="3" class="text-center">Welding Process</th>
<th colspan="3" class="text-center">Welder/Operation No.</th>
<th colspan="2" rowspan="2" class="text-center" >Visual Inspection</th>
<th style="text-align:center;vertical-align:middle;" rowspan="3">Date</th>
<th style="text-align:center;vertical-align:middle;" rowspan="3" >Sign</th>
</tr>
<tr>
<th colspan="3" class="text-center">Passes</th>
<th colspan="3" class="text-center">Passes</th>
</tr>
<tr>
<th class="text-center">Root/Hot</th>
<th class="text-center">Fill</th>
<th class="text-center">Cap</th>
<th class="text-center">Root/Hot</th>
<th class="text-center">Fill</th>
<th class="text-center">Cap</th>
<th class="text-center">Accept</th>
<th class="text-center">Reject</th>
</tr>
<c:forEach begin="1" var="xx" end="10">
<tr>
<c:if test="${xx==1}">
</c:if>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</c:forEach>
<tr>
<td colspan="4">Name & Signature of fabrication foreman</td>
<td colspan="3">Released to</td>
<td colspan="2">
<input type="checkbox">
QC/NDE/DIM.
</td>
<td colspan="1">
<input type="checkbox">
Welding
</td>
<td colspan="4">
<input type="checkbox">
Fabrication/Assembly
</td>
</tr>
<tr>
<td colspan="14">Name & Signature of QC Personel</td>
</tr>
<tr>
<td colspan="7">Date</td>
<td colspan="7">Date</td>
</tr>
</table>
</section>
</div>
<script src="assets/jquery/customjs.js" type="text/javascript"></script>
<script src="assets/jquery/jquery-3.5.1.min.js" type="text/javascript"></script>
<script src="assets/jquery/popper.min.js" type="text/javascript"></script>
<script src="assets/jquery/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>
I need to export this page in landscape and all this content scaled into one page. Is there any way? Thank you in advance.
You can use Flyingsaucer.
Flying Saucer is a pure-Java library for rendering arbitrary
well-formed XML (or XHTML) using CSS 2.1 for layout and formatting,
output to Swing panels, PDF, and images.
hello everyone i've been looking how get data from a list from a jsp and put it into another jsp with a form but i dont know how can i get the id from the list and send it to my form :/ btw im working on netbeans
this is my list.jsp that shows on screen all the errors registered on db
<h1>List of Errors</h1>
<%
ErrorDAO daoaut=new ErrorDAO();
List<ErrorENT> list=daoaut.list();
%>
<table BORDER="3">
<tr>
<td>ID</td><td>DATE</td><td>LOG</td><td>ESTATE</td><td> </td>
</tr>
<% for(ErrorENT aut:list){ %>
<tr>
<td> <%= aut.getIdError()%> </td>
<td> <%= aut.getDate()%> </td>
<td> <%= aut.getLog() %> </td>
<td> <%= aut.isEstate() %> </td>
<td><input type="button" id="btnUpdate" value="Update"/></td>
</tr>
<% } %>
</table>
and somehow when i click on the button Update it should get the id from the row and pass it to my form, but i dont know how to get the id and how it should be recived from the other side :(
Using Hidden Tag Or using anchor tag
<h1>List of Errors</h1>
<%
ErrorDAO daoaut=new ErrorDAO();
List<ErrorENT> list=daoaut.list();
%>
<table BORDER="3">
<tr>
<td>ID</td><td>DATE</td><td>LOG</td><td>ESTATE</td><td> </td>
</tr>
<% for(ErrorENT aut:list){ %>
<form action="Your another jsp" method="post"> // using form for submit to another jsp
<tr>
<td> <%= aut.getIdError()%> </td>
<td> <%= aut.getDate()%> </td>
<td> <%= aut.getLog() %> </td>
<td> <%= aut.isEstate() %> </td>
<td><input type="hidden" value="<%=aut.getIdError()%>" name="id"/></td>
<td><input type="button" id="btnUpdate" value="Update"/></td>
</tr>
</form>
<% } %>
</table>
// now you can IdError from next page using request.getParameter("id");
2 ND METHOD USING anchor tag
<%
ErrorDAO daoaut=new ErrorDAO();
List<ErrorENT> list=daoaut.list();
%>
<table BORDER="3">
<tr>
<td>ID</td><td>DATE</td><td>LOG</td><td>ESTATE</td><td> </td>
</tr>
<% for(ErrorENT aut:list){ %>
<tr>
<td> <%= aut.getIdError()%> </td>
<td> <%= aut.getDate()%> </td>
<td> <%= aut.getLog() %> </td>
<td> <%= aut.isEstate() %> </td>
<td> <input type="button" id="btnUpdate" value="Update"/> </td>
</tr>
</form>
<% } %>
</table>
Actually I prefer to use Servlets or some MVC framework (SpringMVC, Struts2) instead.
However if you want to achieve your target with just using JSPs:
In list.jsp :
//use this :
<td><a href="/otherJsp.jsp?idError=<%= aut.getIdError() %>" > Update </a></td>
//instead of :
<td><input type="button" id="btnUpdate" value="Update"/></td>
In the otherJsp.jsp
//Retrieve the Error ID from request
The Error ID is : <%= request.getParameter("idError") %>
Im stucked in java based selenium usage, i like to click on input box (within table )by another cell text value
Here is my HTML code:
<DIV class=>
<P class=></P>
<UL></UL>
<FORM id="" onsubmit="" method=post name="" action="">
<TABLE width="100%">
<TBODY>
<TR>
<TD class=></TD></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD class=></TD></TR>
<TR>
<TD>
<TABLE class="" width="70%">
<TBODY>
<TR class="">
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="">
<TD><INPUT class="" onclick="" CHECKED type=checkbox><INPUT id= value=true type=hidden name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD></TR></TBODY></TABLE></TD>
<TR>
<TD><INPUT id="" class= onclick='' value="" type=button name=></TD></TR></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class=foo width="100%">
<TBODY>
<TR class=foo-header>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT onclick="" value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD></TR>
<TR class="foo-even">
<TD rowSpan="3"><INPUT onclick="" value="1" CHECKED type="radio" name=""> </TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD rowSpan="3"></TD>
<TD></TD>
<TD rowSpan="3"><INPUT id="" class="" value="" type="" name=""></TD></TR>
<TR class="foo-even">
<TD></TD></TR>
<TR class="foo">
<TD>CCC</TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><INPUT class="" onclick="" type=checkbox><INPUT id="" value="false" type="hidden" name=""> </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=""></TD></TR>
<TR>
<TD>
<TABLE class="foo" width="100%">
<TBODY>
<TR class="foo-header">
<TD></TD>
<TD><BR><INPUT id="" class="" onclick="" value="" type="button" name=""></TD>
<TD colSpan="3"></TD>
<TD></TD></TR>
<TR class="foo-odd">
<TD><INPUT value="0" type="radio" name=""> </TD>
<TD></TD>
<TD></TD>
<TD colSpan="2"></TD>
<TD><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo-even">
<TD rowSpan="2"><INPUT value="1" type="radio" name=""> </TD>
<TD rowSpan="2"></TD>
<TD rowSpan="2"></TD>
<TD></TD>
<TD></TD>
<TD rowSpan="2"><SELECT class="" name=""> <OPTION value="0"></OPTION> <OPTION selected value="1"></OPTION></SELECT> </TD></TR>
<TR class="foo">
<TD>CCC</TD>
<TD></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
</DIV>
I like to click on the second CCC text row related input,(not by only clicking name or xpath) im tried with followings:
driver.findElement(By.xpath(".//td[contains(text(),'CCC')]/preceding-sibling::td")).click();
Code above working in a *very similar html only contains CCC one time (tested with another HTML code )
WebElement services = driver.findElement(By.xpath(".//*[#id='installationAddressForm']/table[4]/tbody/tr[2]/td/table/tbody/tr[4]/td[1][contains(text(),'CCC')]"));
String contents = services.getText();
System.out.println(contents);
Code above able to find text but when combined with the top code(/preceding-sibling::td) it cannot find the input
Please help.Thanks in advance
The expression td[1][contains(text(),'CCC')] selects the first td and tests whether its text contains CCC.
Replace it with td[contains(text(),'CCC')][1].
How can I set acceptable extensions in file dialog using JSP and Spring MVC? This is how I do:
<form:form method="post" enctype="multipart/form-data"
modelAttribute="uploadedFile" action="fileUpload">
<table>
<tr>
<td>Upload File:</td>
<td><input type="file" name="file" /></td>
<td style="color: red; font-style: italic;"><form:errors
path="file" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Upload" /></td>
<td></td>
</tr>
</table>
</form:form>
Can I do something like this with Spring:
<input type="file" name="file" ext="xml, txt"/>
Try this..
<html>
<body>
<input type="file" name="fi" accept="text/xml, text/plain"/>
</body>
</html>
You don't need spring to do this. It is just simple HTML.
I'm have problems linking my HTML and JSP. Just trying to make a simple html page to take a "email" and "password" then have the jsp display on the next page. But when i click submit the parameters dont get passed i just get "null", any ideas where im going wrong?
HTML Page
<html>
<head>
<title>Enter your email and password</title>
</head>
<body>
<form action="form.jsp" method="get">
<table cellspacing="5" border="0">
<tr>
<td align="right">Email:</td>
<td><input type="text" email=email></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="text" password=password></td>
</tr>
<tr>
<td></td>
<td><br><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
JSP Page
<html>
<body>
<%
// get info from request
String email = request.getParameter("email");
String password = request.getParameter("password");
%>
<p>Here is the info you provided:</p>
<table cellspacing="5" cellpadding="5" border="1">
<tr>
<td align="right">Email:</td>
<td><%= email %></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><%= password %></td>
</tr>
</table>
<form action= "Next" method="post">
<input type="submit" value="Return">
</form>
</body>
</html>
You need to use the name attribute in the form fields .
<input type="text" name="email"></td>
The value of "email" can be retrieved in JSP as :
String email = request.getParameter("email");
OR
${param.email}
OR
<c:out value="${param.email}"/> <%--(Using JSTL)--%>
Here are the complete list of attributes.
name = string #
The name part of the name/value pair associated with this element for the purposes of form submission.
You should specify the input name attribute. Try this,
<form action="form.jsp" method="get">
<table cellspacing="5" border="0">
<tr>
<td align="right">Email:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td></td>
<td><br><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
For more info you can try this link