it shows data when get request is send properly but when i save data with post requset then again the page is rendered data is not coming on page
This is my controller code
#RequestMapping(value = "/incident", method = RequestMethod.GET)
public String add_incident(Model model,HttpSession session) {
try{
List<AddIncident> fetchincident = incService.fetchIncident();
String user_id = ""+session.getAttribute("session");
List<AddIncident> fetchuserincident = incService.fetchuserincident(user_id);
//group work
User user = new User();
model.addAttribute("user", user);
List<User> fetchListByUsername = userService.findListByUserName(user_id);
String department = fetchListByUsername.get(0).getDepartment();
List<AddIncident> fetchgroupincident = incService.fetchgroupincident(department);
System.out.println(fetchgroupincident.get(0).getAssignTo());
System.out.println(fetchgroupincident.get(0).getSeverity());
model.addAttribute("fetchincident", fetchincident);
model.addAttribute("fetchgroupincident", fetchgroupincident);
model.addAttribute("fetchuserincident", fetchuserincident);
}catch(Exception e){
e.printStackTrace(); }
AddIncident incident = new AddIncident();
model.addAttribute("incident", incident);
return "incident";
}
#RequestMapping(value = "/incident", method = RequestMethod.POST)
public String add_incident(
#Valid #ModelAttribute("incident") AddIncident incident,
BindingResult result, Model model,HttpSession session) {
if (result.hasErrors()) {
return "incident";
} else {
User user=new User();
System.out.println(""+session.getAttribute("session"));
String user_id = ""+session.getAttribute("session");
System.out.println(user_id);
List<User> fetchListByUsername = userService.findListByUserName(user_id);
String department = fetchListByUsername.get(0).getDepartment();
System.out.println(department);
try{
List<User> fetchgroupuser = userService.findListByGroup(department);
ArrayList<String> email=new ArrayList<String>();
System.out.println(email);
for(User use:fetchgroupuser){
email.add(use.getEmail());
}
String[] to = new String[email.size()];
to = email.toArray(to);
System.out.println(to);
/*new String[]{"irasoftwares6#gmail.com","bluemagictest#gmail.com"};*/
String from = "Anurag.yv19#gmail.com";
String sub= "Incident Management System";
String msgBody="New Incident created";
incService.save(incident);
emailService.sendEmail(to , from, sub, msgBody);
}catch(ArrayIndexOutOfBoundsException e){e.printStackTrace();}
incident_logger.log(INCIDENT, incident.getRef_id()+" \n Assigned to :"+session.getAttribute("session"));
model.addAttribute("message", "Saved incident details");
return "incident";
}
}
my jsp code
<div class="table-responsive" id="inc-table" style="min-height: 280px;">
<form action="" method="get">
<div class="input-group">
<!-- USE TWITTER TYPEAHEAD JSON WITH API TO SEARCH -->
<input class="form-control" id="system-search" name="q" placeholder="Search for" required>
<span class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</form>
<table class="table table-list-search table-bordered table-stripped table-hover">
<thead>
<tr>
<th>Ref. No.</th>
<th>Created</th>
<th>Severity</th>
<th>State</th>
<th>Assigned</th>
<th>Est</th>
<th>Description</th>
<th>Location</th>
<th>Config-item</th>
<th>Symptom Code</th>
<th>Closure Code</th>
<th>Submitted BY</th>
</tr>
</thead>
<tbody>
<c:forEach var="fetchuserincident" items="${fetchuserincident}">
<tr>
<td id="1" class="click" ><a href=""/>${fetchuserincident.ref_id}</td>
<td>${fetchuserincident.created}</td>
<td>${fetchuserincident.severity}</td>
<td>${fetchuserincident.state}</td>
<td>${fetchuserincident.assignTo}</td>
<td>${fetchuserincident.escalation}</td>
<td>${fetchuserincident.description}</td>
<td>${fetchuserincident.location}</td>
<td>${fetchuserincident.config_Item}</td>
<td>${fetchuserincident.symptom_code}</td>
<td>${fetchuserincident.closure_code}</td>
<td>${fetchuserincident.submittedby}</td>
<td> <button id="editbtn" class="fa fa-pencil">Edit</button></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<hr>
<br>
My Group Work
Ref. No.
Created
Severity
State
Assigned
Est
Description
Location
Config-item
Symptom Code
Closure Code
Submitted BY
${fetchgroupincident.ref_id}
${fetchgroupincident.created}
${fetchgroupincident.severity}
${fetchgroupincident.state}
${fetchgroupincident.assignTo}
${fetchgroupincident.escalation}
${fetchgroupincident.description}
${fetchgroupincident.location}
${fetchgroupincident.config_Item}
${fetchgroupincident.symptom_code}
${fetchgroupincident.closure_code}
${fetchgroupincident.submittedby}
Edit
Related
I am new with Spring and Thymeleaf. I am building a simple app to rate films and series. I have a html table with some information about serie including current rating. To display a current rate I need to send a serie id to my spring controller, but don't know how to do that. I was trying with th:with="serie_Id=${tempSerie.id}" but it doesn't work as I wish. The theId variable is always null.
Here is my controller:
#GetMapping("/list")
public String listSeries(#Param("serie_Id") Integer theId, Model theModel, #Param("keyword") String keyword){
String username;
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(principal instanceof UserDetails){
username = ((UserDetails)principal).getUsername();
}
else {
username = principal.toString();
}
System.out.println(theId);
User theUser = userService.findByUsername(username);
Serie theSerie = serieService.findById(theId);
int theRating;
try{
theRating = serieRatingService.findByUserAndSerie(theUser, theSerie).getSerieRating();
}
catch (NullPointerException e){
theRating = 0;
}
List<Serie> theSeries = serieService.findAll(keyword);
theModel.addAttribute("serie_Id", theId);
theModel.addAttribute("series", theSeries);
theModel.addAttribute("ratings", theSeries);
theModel.addAttribute("keyword", keyword);
theModel.addAttribute("theRating", theRating);
return "series/list-series";
}
Here is snippet of my view:
<table class="table table-bordered table-striped">
<thead class="thead-dark">
<tr>
<th>Title</th>
<th>Release Year</th>
<th>Current Rate</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="tempSerie : ${series}">
<td th:text="${tempSerie.title}" />
<td th:text="${tempSerie.release_year}" />
<td>
<p><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-star-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.283.95l-3.523 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
</svg><span th:with="serie_Id=${tempSerie.id}" th:text="${theRating}"></span></p>
</td>
<td>
<div sec:authorize="hasRole('ROLE_ADMIN')">
<a th:href="#{/series/showFormForUpdate(serieId=${tempSerie.id})}"
class="btn btn-info btn-sm">
Update
</a>
<a th:href="#{/series/delete(serieId=${tempSerie.id})}"
class="btn btn-danger btn-sm"
onclick="if (!(confirm('Are you sure?'))) return false">
Delete
</a>
</div>
<div sec:authorize="hasRole('ROLE_USER')">
<a th:href="#{/serieRatings/showFormForSerieRate(serieId=${tempSerie.id})}"
class="btn btn-warning">
Rate
</a>
</div>
</td>
</tr>
</tbody>
</table>
I want my table to be like this. The serie id is just hard-coded.
https://i.stack.imgur.com/3w7yQ.png
Try to change your solution for this one. In general, read about Path Variables.
<a th:href="#{/serieRatings/showFormForSerieRate/${tempSerie.id}}"
class="btn btn-warning">
Rate
</a>
And your controller
#GetMapping("/list/{id}")
public String listSeries(#PathVariable Integer id)
{
serieService.findById(id);
...
}
You can of course do something similar with keyword.
Let me know if it makes the trick.
I added user and my services to model and used them in the view. Maybe this approach is not the best but it works a desired. My controller:
#GetMapping("/list")
public String listSeries(Model theModel, #Param("keyword") String keyword){
String username;
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(principal instanceof UserDetails){
username = ((UserDetails)principal).getUsername();
}
else {
username = principal.toString();
}
User theUser = userService.findByUsername(username);
List<Serie> theSeries = serieService.findAll(keyword);
theModel.addAttribute("series", theSeries);
theModel.addAttribute("keyword", keyword);
theModel.addAttribute("theService", serieService);
theModel.addAttribute("theRatingService", serieRatingService);
theModel.addAttribute("user", theUser);
return "series/list-series";
}
Snippet of my view:
<td th:text="${tempSerie.title}" />
<td th:text="${tempSerie.release_year}" />
<td>
<p><svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-star-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M3.612 15.443c-.386.198-.824-.149-.746-.592l.83-4.73L.173 6.765c-.329-.314-.158-.888.283-.95l4.898-.696L7.538.792c.197-.39.73-.39.927 0l2.184 4.327 4.898.696c.441.062.612.636.283.95l-3.523 3.356.83 4.73c.078.443-.36.79-.746.592L8 13.187l-4.389 2.256z"/>
</svg><span th:text="${theRatingService.findByUserAndSerie(user, theService.findById(tempSerie.id))?.getSerieRating()}"></span></p>
</td>
I am trying post a request to my controller and everytime when I hit submit button it gives an error of bad request.
I am not able to find out what is wrong with the code.
Home.jsp
<div id="setReminder">
<label class="generalReminder" style="text-decoration: none;">General
Reminder</label>
<table>
<tr>
<td>Date</td>
<td><input type="text" readonly="readonly"
id="birthdayDate"></td>
</tr>
<tr>
<td>Time</td>
<td><input type="text" readonly="readonly" id="callTime"
></td>
</tr>
<tr>
<td>Message</td>
<td><textarea id="reminderTag" rows="5"></textarea></td>
</tr>
</table>
</div>
<div id="reminderDot" style="margin-top: 24%; position: relative;">
<button class="submitReminder" onclick="saveReminderDetails();">Submit</button>
</div>
Home.js
function saveReminderDetails(){
var x="";
x=scheduleBirthdayReminder();
if(x){
$.ajax({
type:"POST",
url:"submitBirthdayRequest.do",
data : {
birthdayDate :$("#birthdayDate").val(),
birthdayTime : $("#callTime").val(),
birthdayReminder : $("#reminderTag").val()
},
success : function(data) {
alert('data is'+data);
$("#birthdayDate").val('');
$("#callTime").val('');
$("#reminderTag").val('');
}
});
}
}
Controller.java
#RequestMapping(value="submitBirthdayRequest.do",method=RequestMethod.POST)
public #ResponseBody String submitSchedulerDetails(#RequestParam("birthdayDate")String birthdayDate,#RequestParam("callTime")String birthdayTime,#RequestParam("reminderTag")String reminderTag,HttpServletRequest request ){
System.out.println("adding reminder details with birthdayDate "+birthdayDate+"and time"+birthdayTime);
String userIdentity=((UserDetails)request.getSession(false).getAttribute("loginDetails")).getName();
try{
boolean schedulerObj= schedulerService.addSchedulerBirthdayDetails(userIdentity,birthdayDate, birthdayTime,reminderTag);
}catch(Exception e){
e.printStackTrace();
}
return birthdayTime;
}
Error
http://localhost:8083/Testing/submitBirthdayRequest.do 400 (Bad Request)
the names of the parameters in the request don't match the expected. Try changing the
#RequestParam("birthdayTime") String birthdayTime
#RequestParam("birthdayReminder") String reminderTag
or change the param names on the client side
I have a page that displays the list of all the journals available. I want to write a thymeleaf expression language that highlights the already subscribed journals using there journal id . So for all the subscribed journals the text for the hyper-link href should be "Unsubscribe" and vice verse if its not subscribed.
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<title>TBD</title>
<!--/*/ <th:block th:include="fragments/headinc :: head"></th:block> /*/-->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<h1 th:text="'Hello, ' + ${user.fullname} + '!'" />
<p>Manage your subscriptions here</p>
<form role="form" id="form-search" class="form-inline"
th:action="#{/subscriptions}" method="get">
<input type="text" class="form-control" id="filter" name="filter"
placeholder="Enter filter"></input>
<button type="submit" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span> Search
</button>
<a th:href="#{/logout}" class="btn btn-link" role="button">Logout</a>
</form>
<div th:if="${not #lists.isEmpty(journals)}">
<form role="form" id="form-subscribe" th:action="#{/subscribe}"
method="post">
<input type="hidden" name="journalId" id="journalId" />
</form>
<table id="table" class="table">
<thead>
<tr>
<th>Subject</th>
<th>Filename</th>
<th>Tags</th>
<th>View</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr th:each="journal : ${journals}">
<td th:text="${journal.subject}">Id</td>
<td th:text="${journal.filename}">Product Id</td>
<td th:text="${journal.tags}">Description</td>
<td><a>View</a></td>
<td><a id="href"
th:href="'javascript:subscribe(\'' + ${journal.id} + '\');'">Subscribe</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
<script type="text/javascript">
function subscribe(journalId) {
$('#journalId').val(journalId);
$('#form-subscribe').submit();
}
</script>
<script type="text/javascript" th:inline="javascript">
/*<![CDATA[*/
$(document).ready(function() {
var modelAttributeValue = [[${subscriptions}]];
console.log(modelAttributeValue);
alert(modelAttributeValue);
var array = modelAttributeValue.split(';');
console.log(array);
alert(array);
});
/*]]>*/
</script>
</html>
Controller
#Controller
public class SubscriptionController {
#Autowired
private SubscriberService subscriberService;
#RequestMapping(value = "/subscribe", method = RequestMethod.POST)
String subscribe(Model model, #RequestParam("journalId") Integer journalId) {
JournalToken token = (JournalToken) SecurityContextHolder.getContext().getAuthentication();
Account user = (Account) token.getCredentials();
model.addAttribute("user", user);
Journal journal = this.subscriberService.findJournalById(journalId);
this.subscriberService.subscribeJournalForSubscriber(journal, user);
return "redirect:subscriptions";
}
#RequestMapping(value = "/subscriptions", method = RequestMethod.GET)
String list(Model model) {
JournalToken token = (JournalToken) SecurityContextHolder.getContext().getAuthentication();
Account user = (Account) token.getCredentials();
model.addAttribute("user", user);
ArrayList<Journal> journals = this.subscriberService.FindAllJournals();
model.addAttribute("journals", journals);
StringBuilder sub = new StringBuilder();
ArrayList<Subscription> subscribed = this.subscriberService.getSubscribedJournalsForSubscriber(user);
model.addAttribute("subscriptions", subscribed);
return "subscriptions";
}
}
Model subscriptions
#Entity
#Table(uniqueConstraints={#UniqueConstraint(columnNames={"userId", "journalId"})})
public class Subscription {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
#Version
private Integer version;
private Integer userId;
private Integer journalId;
public void setId(Integer id) {
this.id = id;
}
public Integer getId() {
return this.id;
}
public void setVersion(Integer version) {
this.version = version;
}
public Integer getVersion() {
return this.version;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getUserId() {
return this.userId;
}
public void setJournalId(Integer journalId) {
this.journalId = journalId;
}
public Integer getJournalId() {
return this.journalId;
}
}
you can change your arrayList subscribed to have only the ids of journals (more optimised).
So, in the controller you can have something like this
ArrayList<Integer> subscribed =
this.subscriberService.getSubscribedJournalsForSubscriber(user); //modify it so it returns the journals ids instead of the whole object(Subscription)
then in the thymeleaf change the anchor with something like this
<a id="href" th:href="'javascript:subscribe(\'' + ${journal.id} + '\');'">
<span th:if="${#lists.contains(subscriptions, journal.id) }" th:text="Unsubscribe"> Unsubscribe </span>
<span th:if="not ${#lists.contains(subscriptions, journal.id) }" th:text="Subscribe"> Subscribe </span>
</a>
Have a look at the documentation of thymeleaf http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html
/*
* Check if element or elements are contained in list
*/
${#lists.contains(list, element)}
${#lists.containsAll(list, elements)}
I am using Spring Framework to develop a web app.
The problem is when i tried to add an article in my database It shows a NestedServlet exception. Can any one help me ?
This is my controler class :
#Controller
public class Controler {
ArticleFacadeLocal articleModel;
CategorieFacadeLocal categorieModel;
ConnexionFacadeLocal connexionModel;
public Controler(){
articleModel = new ArticleModel();
categorieModel = new CategorieModel();
connexionModel = new ConnexionModel();
}
#RequestMapping("/home.do")
public String home(HttpServletRequest request){
if(isConnected(request))
return addPage(request);
else return "page:login";
}
#RequestMapping("login.do")
public String login(HttpServletRequest request){
String login=request.getParameter("login");
String password=request.getParameter("password");
if(ConnexionModel.connect(login, password)){
request.getSession().setAttribute("login",login);
ServletContext application=request.getServletContext();
application.setAttribute("categories", categorieModel.findAll());
return addPage(request);}
else
request.setAttribute("error",true);
return "forward:/home.do";
}
#RequestMapping("logout.do")
public String logout(HttpServletRequest request) {
request.getSession(false).invalidate();
return "forward:/home.do";
}
#RequestMapping("articles.do")
public String list(HttpServletRequest request){
request.setAttribute("articles",articleModel.findAll());
return "page:articles";
}
#RequestMapping("addPage.do")
public String addPage(HttpServletRequest request){
request.setAttribute("categories", categorieModel.findAll());
return "page:add";
}
#RequestMapping("add.do")
public String add(HttpServletRequest request){
try{
Article a=getArticleFromView(request);
articleModel.create(a);
request.setAttribute("error", false);
}catch(Exception e){request.setAttribute("error", true);}
return "forward:/addPage.do";
}
#RequestMapping("modifyPage.do")
public String modiyPage(HttpServletRequest request){
int idArticle=Integer.parseInt(request.getParameter("idArticle"));
request.setAttribute("categories", categorieModel.findAll());
Article article = articleModel.find(idArticle);
request.setAttribute("article", article);
return "page:modify";
}
#RequestMapping("modify.do")
public String modify(HttpServletRequest request){
try{
Article a=getArticleFromView(request);
articleModel.edit(a);
return "forward:/articles.do";
}catch(Exception e){
request.setAttribute("error", true);
return "forward:/modifyPage.do";
}
}
#RequestMapping("searchPage.do")
public String searchPage(HttpServletRequest request){
return "page:search";
}
#RequestMapping("search.do")
public String search(HttpServletRequest request){
String libelle=request.getParameter("libelle");
request.setAttribute("article",articleModel.find(libelle));
return "page:search";
}
public boolean isConnected(HttpServletRequest request){
HttpSession session = request.getSession(false);//recupere une session sans la creer
return (session!=null && session.getAttribute("login")!=null);
}
public Article getArticleFromView(HttpServletRequest request){
Article a = new Article();
String libelle = request.getParameter("libelle");
String description = request.getParameter("description");
String prix = request.getParameter("prix");
String qte = request.getParameter("qte");
String categorie = request.getParameter("categorie");
a.setLibelle(libelle);
a.setDescription(description);
a.setPrix(Double.parseDouble(prix));
a.setQte(Integer.parseInt(qte));
a.setCategorie(new Categorie(categorie));
return a;
}
}
And this is my jsp file
<%#include file="include.jsp" %>
<form action="add.do" method="post">
<table align="center">
<tr >
<td>Libelle :
<td><input type="text" required="required" name="libelle"/>
</tr>
<tr >
<td>Description :
<td><input type="text" required="required" name="description">
</tr>
<tr>
<td>Prix :
<td><input type="text" required="required" name="prix">
</tr>
<tr>
<td>Quantité :
<td><input type="text" required="required" name="qte">
</tr>
<tr >
<td> Catégorie :
<td>
<select name="categorie" >
<c:forEach items="${categories}" var="c">
<option value="${c.idCategorie}"> ${c.libelleCategorie} </option>
</c:forEach>
</select>
</tr>
<tr align="center" >
<td colspan="2"><button type="submit" id="btn">Ajouter</button></td>
</tr>
</table>
</form>
<c:if test="${not empty error && error}"> <p style="color: red;"> Echec d'ajout de l'article </p></c:if>
<c:if test="${not empty error && not error}"> <p style="color: green;">Article ajouté avec succes </p></c:if>
This is error exception :
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.AssertionFailure: null id in model.beans.Article entry (don't flush the Session after an exception occurs)
cause première
org.hibernate.AssertionFailure: null id in model.beans.Article entry (don't flush the Session after an exception occurs)
I am not using Maven.
Hi I am reading image from MongoDB and trying to pass that to JSP page but it is not passing properly from my controller. i am thinking i am almost edge to the solution but not getting exactly where i am doing mistake. Please let me know if you find any mistake.
here insertMedia method reading image from file and storing into DB and then returning back that image.
i am passing userMediaSave as image value to JSP, you can get that at tag like
img src=${userMediaSave} alt="Profile images"
My Controller:
#RequestMapping(value = "/userMediaSave", method = RequestMethod.GET)
public ModelAndView mediaLoadSuccess(HttpServletRequest request,HttpServletResponse response,
#ModelAttribute("mediaBean") MediaBean mediaBean) throws IOException, ServletException {
ModelAndView model = null;
File filePart = mediaBean.getMediaImage();
if (filePart != null) {
InputStream inputStream = new FileInputStream(filePart);
GridFSDBFile imageForOutput = null;
try {
imageForOutput = loginDelegate.insertMedia(inputStream, request.getContentType(), filePart.getName());
mediaBean.setExistedMedia(imageForOutput);
OutputStream out= null;
if(imageForOutput!=null){
InputStream is = imageForOutput.getInputStream();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
byte[] data = new byte[16384];
while ((nRead = is.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
}
byte[]imagenEnBytes = buffer.toByteArray();
buffer.flush();
response.setContentType("image/jpg" );
response.setContentLength(imagenEnBytes.length);
model = new ModelAndView("userMedia");
request.setAttribute("userMediaSave", imagenEnBytes);
return model;
} else {
System.out.println("inside uploadMedia page -ve");
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
//out.close();
}
}
return model;
}
JSP is:
<body onload="checkMessage()">
<form:form id="mediaForm" method="get" action="userMediaSave" modelAttribute="mediaBean">
<table border="1" cellpadding="1" cellspacing="1"
style="width: 500px;" align="center">
<tbody>
<tr>
<td colspan="4" align="center">Name : Welcome to Media App</td>
</tr>
<tr>
<td rowspan="3">Profile Image</td>
<td>Upload Images</td>
<td><input type="file" name="mediaImage" /></td>
</tr>
<tr>
<td> </td>
<td><input name="upload" type="submit" value="Upload" /></td>
</tr>
</tbody>
</table>
<table border="1" cellpadding="1" cellspacing="1"
style="width: 500px;" align="center">
<tbody>
<tr>
<td>User has some existed Media Album</td>
</tr>
<tr>
<td>
<img src=${userMediaSave} alt="Profile images" style="width:100px;height:100px;">
</td>
</tr>
</tbody>
</table>
</form:form>
am i passing image from controller to JSP properly? if not please let me know which way i have to pass it.